- 场景
定时任务用于在指定的时间内循环或单次执行一些命令或脚本。
- 实例
[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这个脚本。