系统相关
首页 > 系统相关> > linux-crontab

linux-crontab

作者:互联网

centos安装crontab

 yum install crontabs

crontab -e #编辑crontabs页面
crontab -l #查看任务

注意:执行时linux原生系统是少了8小时的,如果需要定时需要加上8小时

每十秒执行一次

* * * * * /usr/bin/python  /opt/testWrite.py >>  /opt/testWrite1.log 2>&1

* * * * * sleep 10; /usr/bin/python  /opt/testWrite.py >>  /opt/testWrite1.log 2>&1

* * * * * sleep 20; /usr/bin/python  /opt/testWrite.py >>  /opt/testWrite1.log 2>&1

* * * * * sleep 30; /usr/bin/python  /opt/testWrite.py >>  /opt/testWrite1.log 2>&1

* * * * * sleep 40; /usr/bin/python  /opt/testWrite.py >>  /opt/testWrite1.log 2>&1

* * * * * sleep 50; /usr/bin/python  /opt/testWrite.py >>  /opt/testWrite1.log 2>&1

实例1:每1分钟执行一次myCommand

实例2:每小时的第3和第15分钟执行
3,15 * * * * myCommand

实例3:在上午8点到11点的第3和第15分钟执行
3,15 8-11 * * * myCommand

实例4:每隔两天的上午8点到11点的第3和第15分钟执行
3,15 8-11 */2 * * myCommand

实例5:每周一上午8点到11点的第3和第15分钟执行
3,15 8-11 * * 1 myCommand

实例6:每晚的21:30重启smb
30 21 * * * /etc/init.d/smb restart

实例7:每月1、10、22日的4 : 45重启smb
45 4 1,10,22 * * /etc/init.d/smb restart

实例8:每周六、周日的1 : 10重启smb
10 1 * * 6,0 /etc/init.d/smb restart

实例9:每天18 : 00至23 : 00之间每隔30分钟重启smb
0,30 18-23 * * * /etc/init.d/smb restart

实例10:每星期六的晚上11 : 00 pm重启smb
0 23 * * 6 /etc/init.d/smb restart

实例11:每一小时重启smb
0 */1 * * * /etc/init.d/smb restart

实例12:晚上11点到早上7点之间,每隔一小时重启smb
0 23-7/1 * * * /etc/init.d/smb restart

标签:opt,11,15,crontab,etc,实例,linux,smb
来源: https://www.cnblogs.com/starSgz/p/16482012.html