# Subtract Seconds from Date Command

**URL:** <https://community.unix.com/t/subtract-seconds-from-date-command/354584>\
**Category:** Shell Programming and Scripting\
**Created:** [August 11, 2015, 2:54am UTC](https://community.unix.com/t/subtract-seconds-from-date-command/354584 "2015-08-11T02:54:23Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![refra](https://community.unix.com/letter_avatar/refra/32/6_449c533f586939b6e5f246632a46421f.png) [@refra](https://community.unix.com/u/refra)\
**Post date:** [August 11, 2015, 2:54am UTC](https://community.unix.com/t/subtract-seconds-from-date-command/354584/1 "2015-08-11T02:54:23Z")

</div>

Hi,

Need to subtract 5 seconds after syncing my Linux server from NTP like;

#ntpdate time.myorg.int.

This script will only run once in each morning at 9 AM.

Please help me.

---

<div class="post-metadata">

**Author:** ![Don\_Cragun](https://community.unix.com/user_avatar/community.unix.com/don_cragun/32/2682_2.png) [@Don\_Cragun](https://community.unix.com/u/Don_Cragun)\
**Post date:** [August 11, 2015, 3:07am UTC](https://community.unix.com/t/subtract-seconds-from-date-command/354584/2 "2015-08-11T03:07:44Z")

</div>

What operating system and shell are you using?

Please explain more clearly what you are trying to do? Are you saying that you want to synchronize the clock on your system to run 5 seconds behind the time used by rest of the world?

---

<div class="post-metadata">

**Author:** ![refra](https://community.unix.com/letter_avatar/refra/32/6_449c533f586939b6e5f246632a46421f.png) [@refra](https://community.unix.com/u/refra)\
**Post date:** [August 11, 2015, 4:24am UTC](https://community.unix.com/t/subtract-seconds-from-date-command/354584/3 "2015-08-11T04:24:01Z")

</div>

My OS is Oracle Linux Enterprise 5.8 and shell is bash

---

<div class="post-metadata">

**Author:** ![Don\_Cragun](https://community.unix.com/user_avatar/community.unix.com/don_cragun/32/2682_2.png) [@Don\_Cragun](https://community.unix.com/u/Don_Cragun)\
**Post date:** [August 11, 2015, 4:33am UTC](https://community.unix.com/t/subtract-seconds-from-date-command/354584/4 "2015-08-11T04:33:42Z")

</div>

OK. So, you can use `date` with a `-d` option.

But, since you didn't answer my second question, I have no idea what other arguments you might want to pass `date` nor what to do with the results.

---

<div class="post-metadata">

**Author:** ![RudiC](https://community.unix.com/letter_avatar/rudic/32/6_449c533f586939b6e5f246632a46421f.png) [@RudiC](https://community.unix.com/u/RudiC)\
**Post date:** [August 11, 2015, 4:34am UTC](https://community.unix.com/t/subtract-seconds-from-date-command/354584/5 "2015-08-11T04:34:52Z")

</div>

With a recent enough `bash` , try

```nohighlight
printf "%s\n" $(($(printf "%(%s)T - 5") ))

```
