crontab用于创建定时任务。
# crontab –e
# 在每天早上5点运行 /root/bin/backup.sh
0 5 * * * /root/bin/backup.sh
语法
{minute} {hour} {day-of-month} {month} {day-of-week} {full-path-to-shell-script}
minute: 区间为 0 – 59
hour: 区间为0 – 23
day-of-month: 区间为0 – 31
month: 区间为1 – 12. 1 是1月. 12是12月.
Day-of-week: 区间为0 – 7. 周日可以是0或7.
更多示例
# 在凌晨过一分钟运行备份(此时系统负载不大)
1 0 * * * /root/bin/backup.sh
# 每过5分钟运行一次
*/5 * * * * cd /.../des; sh angel_hour.sh >> angel_hour.log 2>&1