Linux - CentOS 7 - 定时任务

  • 场景
    定时任务用于在指定的时间内循环或单次执行一些命令或脚本。

  • 实例
[cat@cathome ~]# vim /etc/crontable
SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root

# For details see man 4 crontabs
# Example of job definition:
# .---------------- minute (0 - 59)
# |  .------------- hour (0 - 23)
# |  |  .---------- day of month (1 - 31)
# |  |  |  .------- month (1 - 12) OR jan,feb,mar,apr ... 
# |  |  |  |  .---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat
# *  *  *  *  * user-name  command to be executed 
*/3 * * * * root /opt/script/cscReportSendMail.sh >> /opt/script/cscReport.log

这里存在五个"*",第1个*代表分钟,第2个*为小时,第3*个为日,第4个*为月份, 第5个*为星期。如上面示例,每3分钟执行一次/opt/script/scsReportSendMail.sh这个脚本。

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

友情链接更多精彩内容