Aron Glover
Aron Glover

Reputation: 385

excecuting crontab linux in hour:minutes:[miliseconds]

How can i run bash file in hour : minutes : milliseconds

like 8 : 30 : 800(milliseconds)

This is my code :

30 8 * * * cd /home/req && sh notify.sh

Upvotes: 0

Views: 62

Answers (1)

Mark
Mark

Reputation: 4455

30 8 * * * sleep .8 ; cd /home/req && sh notify.sh

The above code will execute notify.sh sometime after 8:30 and 800 ms. We can do better, but we'll never be exact. Consider rather than hard coding the sleep for 800 ms (.8 seconds) we determine the sleep time from the current time and sleep until the time will be more closely 8:30:00.800 .

It depends on your requirements. If you need to execute notify after 8:30:00.800, my solution works. If you want to get closer to the exact time, we have to be a little smarter.

Upvotes: 1

Related Questions