以下是 crontab 文件的格式:
{minute} {hour} {day-of-month} {month} {day-of-week} {full-path-to-shell-script}
crontab –l 查看有哪些定时任务
crontab –r 删除定时任务
crontab file 添加定时任务
grep –v grep 忽略
表示每分钟执行一次
* * * * * /home/a.sh
启动cron进程的方法:/etc/init.d/crond start
开机就启动cron进程的设置命令:chkconfig --add crond
常用:
每15分钟执行一次:*/15 * * * * /usr/sbin/ntpdate 127.0.0.1
每5小时执行一次:0 */15 * * * /usr/sbin/ntpdate 127.0.0.1
每个工作日 11 p.m 运行:0 23 * * 1-5 /usr/sbin/ntpdate 127.0.0.1
每天早上6点10分:10 6 * * * /usr/sbin/ntpdate 127.0.0.1