Linux crontab usage notes and linuxcrontab notes

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.