2008年1月9日 星期三

Crontab不同的寫法

從來寫Crontab都是照著寫而已,

沒想到Crontab還可以這樣寫

Crontab一般的格式是

18 10 5 * * * root /usr/sbin/ntpdate tock.stdtime.gov.tw && /sbin/hwclock -w
對應到
m h dom mon dow user command

field allowed values
----- --------------
minute 0-59
hour 0-23
day of month 1-31
month 1-12 (or names, see below)
day of week 0-7 (0 or 7 is Sun, or use names)
不過還有另一種寫法 ex:
@hourly root /usr/sbin/ntpdate tock.stdtime.gov.tw && /sbin/hwclock -w
說明如下 :p
string meaning
------ -------
@reboot Run once, at startup.
@yearly Run once a year, "0 0 1 1 *".
@annually (same as @yearly)
@monthly Run once a month, "0 0 1 * *".
@weekly Run once a week, "0 0 * * 0".
@daily Run once a day, "0 0 * * *".
@midnight (same as @daily)
@hourly Run once an hour, "0 * * * *".
詳細的資訊可以 man 5 crontab

沒有留言: