shell 脚本 定时任务配置
参考这个: https://www.yisu.com/zixun/407480.html
添加定时任务
1、执行 crontab -e
2、选择 2
3、编辑定时任务内容 0 */3 * * * /home/XXXX/time.sh (三小时自动触发一次)
4、查看设置任务是否成功 crontab -l
5、重启cron:sudo service cron restart
新加入的定时任务不会马上执行,一般要等一会儿,除非你重启服务器
时间: * * * * * test .sh 每分钟执行一次 test .sh
*/5 * * * * test .sh 每5分钟执行一次 test .sh
0 */2 * * * test .sh > out 每两小时执行一次test.sh并将结果存入out中
00 00 * * * /home/rich/test.sh 每天的凌晨0:0分执行
30 21 * * * /home/rich/test.sh 每天的21:30分执行
15 16 * * 1 command 每周一16:15 运行命令
00 12 1 * * command 每个月的1号的中午12:00点执行命令
00 8* * * if [date +%d -d tomorrow = 01 ] ; then ; command 每个月的最后一天8点执行命令
cron (周期定时任务管理器)