On Linux, plan your task for hour, minute, second accuracy

I just want to run a shell script to say this exact time "16:22:36". Utilities like "at" are useless because they don't have "seconds". "Sleep" does not work, because the cycle ends 8 hours ahead of time for some reason: s, I searched all over Google and could not find any tools. therefore, a huge OS such as Linux does not have a suitable task scheduler?

+3
source share
3 answers

There is cronno second accuracy planning in the standard , since

  • Unix server administration traditionally rarely requires one-second accuracy.
  • , " "

sleep(1) GNU Coreutils .

: 12:14:05 12:14:10

$ crontab -l
(snip...)
14 12 * * * sleep 5; date > /tmp/plain.txt
14 12 * * * while [ "1410" -gt "$(date +\%M\%S)" ]; do /bin/sleep 0.1; done; date > /tmp/while.txt

( ...)

$ ls -l --time-style=full-iso /tmp/*.txt
-rw-r--r-- 1 nodakai nodakai 43 2014-02-22 12:14:06.236151567 +0800 /tmp/plain.txt
-rw-r--r-- 1 nodakai nodakai 43 2014-02-22 12:14:10.007600677 +0800 /tmp/while.txt

1- , 14 12 crontab 12:14:00 sharp. while sleep(1) .

, , NTP , .

+7

crontab 36

22 16 * * * sleep 36; shell_script.sh
+4

Linux has a wonderful task scheduler called crontab. There is a lot of information on the Internet about this. How simple "this is what it does and how to use it," though: http://kvz.io/blog/2007/07/29/schedule-tasks-on-linux-using-crontab/ - I have to start you.

0
source

All Articles