您的位置:首页 > 运维架构 > Linux

crontab - auto execute schedule on unix/linux

2010-07-04 15:59 295 查看
Two usefull command:

crontab -l # list all the crontab task exist

crontab -e # edit this crontab schedule

#(default editor is vi if you want to change modify the VISUAL env variable using comman setenv)

Crontab format : reference from wikepedia

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

Examples : execute my backup.sh every day at 2' aclock

0 2 * * * /home/oracle/bin/backup.sh

More examples of format:

#every 5 minutes

*/5 * * * * command to be executed

#from 6 to 12 aclock every 20 minutes

0 6-12/3 * * * command to be execute

#first day every month and monday to friday at 8 and 18 aclock

0 8,18 1 * mon-fri command to be execute

One tip you can use the way followed to edit your contab schedule:

crontab -l>tmp

vi tmp

crontab tmp
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: