格式
* * * * * command
分 时 日 月 周 命令
minute 0~59
hour 0~23
day 0~31
month 1~12
week 0~7,0或7代表星期日
1 | * * * * * 每分钟 |
创建
创建任务
1 | crontab -e |
查看任务
1 | crontab -l |
查看日志
1 | cat /var/log/cron |
启动
1 | /sbin/service crond start |
示例
基本
1 | * * * * * date >> date.txt |
执行sh脚本
1 | */30 * * * * /root/update-hexo.sh |
参考
Crontab in Linux with 20 Useful Examples to Schedule Jobs
Crontab error “/bin/sh: root: command not found”
Where can I set environment variables that crontab will use?