- # centos
- yum -y install vixie-cron
- yum -y install crontabs
-
- #ubuntu
- apt install cron
-
- service cron start
- service cron restart
- service cron stop
- service cron status
-
- crontab -e
-
编辑文件
- * * * * * myCommand
-
5个参数分别代表 分、时、日、月、周
- # 每1分钟执行一次myCommand
- * * * * * myCommand
-
- # 每小时的第3和第15分钟执行
- 3,15 * * * * myCommand
-
- # 在上午8点到11点的第3和第15分钟执行
- 3,15 8-11 * * * myCommand
-
- # 每隔两天的上午8点到11点的第3和第15分钟执行
- 3,15 8-11 */2 * * myCommand
-
- # 每周一上午8点到11点的第3和第15分钟执行
- 3,15 8-11 * * 1 myCommand
-
- # 每月1、10、22日的4 : 45重启smb
- 45 4 1,10,22 * * /etc/init.d/smb restart
-
- # 每周六、周日的1 : 10重启smb
- 10 1 * * 6,0 /etc/init.d/smb restart
-
- # 每天18 : 00至23 : 00之间每隔30分钟重启smb
- 0,30 18-23 * * * /etc/init.d/smb restart
-
- # 每星期六的晚上11 : 00 pm重启smb
- 0 23 * * 6 /etc/init.d/smb restart
-
- # 每一小时重启smb
- 0 */1 * * * /etc/init.d/smb restart
-
- # 晚上11点到早上7点之间,每隔一小时重启smb
- 0 23-7/1 * * * /etc/init.d/smb restart
-