作者:david_zhang@sh 【轉載時請以超鏈接形式標明文章】
鏈接:http://www.cnblogs.com/david-zhang-index/archive/2012/05/07/2487150.html
配置文件 vi /etc/crontab
第1列分鍾1~59
第2列小時1~23(0表示子夜)
第3列日1~31
第4列月1~12
第5列星期0~6(0表示星期天)
第6列要運行的命令
下面是crontab的格式:
基本格式 :
* * * * * command
分 時 日 月 周 命令
這里有crontab文件條目的一些例子:
30 21 * * * /usr/local/apache/bin/apachectl restart |
45 4 1,10,22 * * /usr/local/apache/bin/apachectl restart |
10 1 * * 6,0 /usr/local/apache/bin/apachectl restart |
0,30 18-23 * * * /usr/local/apache/bin/apachectl restart |
0 23 * * 6 /usr/local/apache/bin/apachectl restart |
0 * * * * /usr/local/apache/bin/apachectl restart |
* */1 * * * /usr/local/apache/bin/apachectl restart |
* 23-7/1 * * * /usr/local/apache/bin/apachectl restart |
0 11 4 * mon-wed /usr/local/apache/bin/apachectl restart |
|
如果要運行一些復雜命令或多條指令可寫成shell來運行