網頁

2009年6月9日 星期二

crontab

Crontab command
#export to the file
crontab -l > filename
# import from the file
crontab filename 
# import from the file for the specific user
crontab -u user filename 
# edit
crontab -e 
# delete all
crontab -r 

Crontab special usage 


EntryDescriptionEquivalent To
@rebootRun once, at startup.None
@yearlyRun once a year0 0 1 1 *
@annually(same as @yearly)0 0 1 1 *
@monthlyRun once a month0 0 1 * *
@weeklyRun once a week0 0 * * 0
@dailyRun once a day0 0 * * *
@midnight(same as @daily)0 0 * * *
@hourlyRun once an hour0 * * * *


Crontab Example

# .---------------- minute (0 - 59) 
# | .------------- hour (0 - 23)
# | | .---------- day of month (1 - 31)
# | | | .------- month (1 - 12) OR jan,feb,mar,apr ...
# | | | | .---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat
# | | | | |
# * * * * * command to be executed

minhourday/monthmonthday/week Execution time
30011,6,12*-- 00:30 Hrs  on 1st of Jan, June & Dec.

:

020*101-5--8.00 PM every weekday (Mon-Fri) only in Oct.

:

001,10,15**-- midnight on 1st ,10th & 15th of month

:

5,10010*1-- At 12.05,12.10 every Monday & on 10th of every month
:

 
*/8 * * * * root init 6  After 8 minutes , execute "reboot" command
ps: "*/8" in the minute time field is equivalent to "0,8,16,24,32,48,56"

沒有留言:

張貼留言