Commands scheduled by cron in CentOS

Source: Internet
Author: User
1: install [php] viewplaincopyyuminstallvixie-cronyuminstallcronta

1: Installation

 

[Php]View plaincopy
  1. Yum install vixie-cron
  2. Yum install crontabs
  3. Chkconfig crond on // start the service

 

 

 

2: Description of the global configuration file (/etc/crontab)

 

[Php]View plaincopy
  1. SHELL =/bin/bash
  2. PATH =/sbin:/bin:/usr/sbin:/usr/bin
  3. MAILTO = root
  4. HOME =/
  5. # Run-parts
  6. 01 *** root run-parts/etc/cron. hourly
  7. 02 4 *** root run-parts/etc/cron. daily
  8. 22 4 ** 0 root run-parts/etc/cron. weekly
  9. 42 4 1 ** root run-parts/etc/cron. monthly

 

 

 

The above are all default values. To put it simply:

 

# Run-parts:

 

The first section should be defined as minute, which indicates the minute of every hour for execution. The range is from 0 to 59. The second segment should be defined as: Hour, which indicates the number of hours for execution. The range is from 0 to 23.

The third paragraph should be defined as: date, which indicates execution from the day of each month, range from 1-31

The fourth part should be defined as month, which indicates the number of months of the year to be executed, ranging from 1 to 12.

The fifth part should be defined as Week, which indicates the day of the week for execution, ranging from 0 to 6, where 0 indicates Sunday.

The user name should be defined in each section, that is, the user in which the execution program is to be executed, which can be omitted;

Section 7 should define the commands and parameters to be executed.

 

01 * root run-parts/etc/cron. hourly indicates the first minute of every hour to start executing executable programs or scripts in the/etc/hourly directory;

02 4 * root run-parts/etc/cron. daily indicates that the executable program or script under the/etc/cron. daily directory is started at 04:02 every day;

2 4 ** 0 root run-parts/etc/cron. weekly...

42 4 1 ** root run-parts/etc/cron. monthly

 

 

Text:

 

1: Set the server to restart at a certain time

 

Vi/etc/crontab

 

[Php]View plaincopy
  1. # Reboot is set to restart at every day
  2. 30 10 * root/sbin/reboot

 

 

 

Remember to restart the crond service: service crond restart

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.