1. Installation
Service Crond Status
Yum Install Vixie-cron
Yum Install Crontabs
2. Example
Print the current time to the log file every minute
#crontab-E
*/1 * * * * Date >>/tmp/date.txt
#tail-F/tmp/date.txt (dynamic display of the file)
#crontab-e-u username
0-58/2 * * * * echo "even***\n"
#crontab-L-u username
#tail-F/var/log/cron
3. Format
*/minute */hour */day */month */weekday COMMAND
#每晚21:30 Restart Apache
* * * Service httpd restart
#每月1, 10, 22nd, 4:45 restart Apache
4 1,10,22 * * Service httpd restart
#每月1到10日4:45 Restart Apache
4 1-10 * * Service httpd restart
#每隔两分钟重启Apache
*/2 * * * * Service httpd restart
1-59/2 * * * * Service httpd restart
#晚上11点到早上7点之间, restart Apache every hour
0 23-7/1 * * * Service httpd restart
#每天18:00 to 23:00 restart Apache every 30 minutes
0-59/30 18-23 * * * Service httpd restart
#低一级的时间不能用 ' * ', ' */a ' means execute once per second
*/30 18-23 * * * Service httpd restart #每30分钟执行一次
4. Configuration
/etc/crontab #系统级crontab
/var/spool/cron/username #username对应的crontab #crontab-e-L
5. Log
/var/log/cron
/var/spool/cron #该目录下存放各个用户的crontab
/var/spool/mail #该目录下存放各个用户的cron邮件信息
6. Error
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Linux under crontab Use notes