以下是 crontab 文件的格式:
{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.
Crontab 选项
以下是 crontab 的有效选项:
crontab –e : 修改 crontab 文件. 如果文件不存在会自动创建。
crontab –l : 显示 crontab 文件。
crontab -r : 删除 crontab 文件。
crontab -ir : 删除 crontab 文件前提醒用户。
示例:
输入crontab -e,进入编辑器,输入表达式即可,如下图:每两分钟执行一次