crontab
#crontabl –l 查看自动执行任务列表
#crontabl –e 编译自动执行任务列表
用户所建立的Crontab文件存于/var/spool/cron中,其文件名与用户名一致。
它的格式共分为六段,前五段为时间设定段,第六段为所要执行的命令段,
格式如下:* ** * * command
其时间段的含义如表二:
段 |
含义 |
取值范围 |
第一段 |
代表分钟 |
0—59 |
第二段 |
代表小时 |
0—23 |
第三段 |
代表日期 |
1—31 |
第四段 |
代表月份 |
1—12 |
第五段 |
代表星期几,0代表星期日 |
0—6 |
例子
45 4 1,10,22 * */usr/local/etc/rc.d/lighttpd restart
上面的例子表示每月1、10、22日的4 : 45重启lighttpd
10 1 * * 6,0 /usr/local/etc/rc.d/lighttpdrestart
上面的例子表示每周六、周日的1: 10重启lighttpd
0,30 18-23 * * */usr/local/etc/rc.d/lighttpd restart
上面的例子表示在每天18 :00至23 : 00之间每隔30分钟重启lighttpd 。
0 23 * * 6/usr/local/etc/rc.d/lighttpd restart
上面的例子表示每星期六的11: 00 pm重启lighttpd
* */1 * * * /usr/local/etc/rc.d/lighttpdrestart
每一小时重启lighttpd
* 23-7/1 * * */usr/local/etc/rc.d/lighttpd restart
晚上11点到早上7点之间,每隔一小时重启lighttpd
0 11 4 * mon-wed /usr/local/etc/rc.d/lighttpdrestart
每月的4号与每周一到周三的11点重启lighttpd
0 4 1 jan */usr/local/etc/rc.d/lighttpd restart
一月一号的4点重启lighttpd
重启下crontab服务,service crontab restart
/etc/init.d/cron restart
# /etc/init.d/crond start