Linux crontab usage notes and linuxcrontab notes
1. Install
Service crond status
Yum install vixie-cron
Yum install crontabs
2. Instance
Print the current time to the log file every minute
# Crontab-e
*/1 ***** date>/tmp/date.txt
# Tail-f/tmp/date.txt (this file is dynamically displayed)
# 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
# Restart Apache at every night
30 21 *** service httpd restart
# Restart Apache at on May 1, 10, and 22 every month
45 4, 10, 22 ** service httpd restart
# Restart Apache at from the first day of every month
45 4 1-10 ** service httpd restart
# Restart Apache every two minutes
*/2 ***** service httpd restart
1-59/2 *** service httpd restart
# Restart Apache every hour between PM and PM
0 23-7/1 *** service httpd restart
# Restart Apache every 30 minutes from to every day
0-59/30 18-23 *** service httpd restart
# The lower-level time cannot be '*', and '*/A' indicates that the execution is performed once every A second.
*/30 18-23 *** service httpd restart # Run once every 30 minutes
4. Configuration
/Etc/crontab # system-level crontab
/Var/spool/cron/username # crontab corresponding to username # crontab-e-l
5. Logs
/Var/log/cron
/Var/spool/cron # store the crontab of each user in this directory
/Var/spool/mail # The cron mail information of each user is stored in this directory.
6. Error
Copyright Disclaimer: This article is an original article by the blogger and cannot be reproduced without the permission of the blogger.