Usage of crontab-E in centos

Source: Internet
Author: User
Install crontab:
[Root @ centos ~] # Yum install vixie-cron
[Root @ centos ~] # Yum install crontabs

Note:
The vixie-cron package is the master of cron.Program;
The crontabs package is used to install, uninstall, or list the tables used to drive the cron daemon.

Cron is a built-in service of Linux, but it does not automatically get up. You can start or close this service using the following methods:
/Sbin/service crond start // start the service
/Sbin/service crond stop // close the service
/Sbin/service crond restart // restart the service
/Sbin/service crond reload // reload the configuration

View crontab service status: Service crond status

Start the crontab service manually: Service crond start

Check whether the crontab service is set to start at startup. Run the following command: ntsysv.

Add boot auto start:
Chkconfig -- level 35 crond on

1. crontab command

Function Description: sets a timer.

Syntax: crontab [-u <User Name>] [configuration file] or crontab [-u <User Name>] [-ELR]

Note: cron is a resident service that provides the timer function to allow users to execute preset commands or programs at specific times. You can use the timer function as long as you edit the timer configuration file. The configuration file format is as follows:
Minute hour day month dayofweek command

Parameters:
-E: edit the timer settings of the user.
-L list the timer settings of this user.
-R: Delete the timer settings of this user.
-U <User Name> specifies the user name to set the timer.

2. crontab format

Basic Format:
* *** Command
Hour, day, month, and week commands

The 1st column indicates minute 1 ~ 59. Each minute is represented by * or */1.
The first column indicates the hour 1 ~ 23 (0 indicates 0 points)
The 3rd column indicates the date 1 ~ 31
The 4th column indicates the month 1 ~ 12
The Identification Number of column 5th is from day of the week to day ~ 6 (0 indicates Sunday)
6th columns of commands to run

Some examples of crontab files:

30 21 ***/usr/local/etc/rc. d/Lighttpd restart
The preceding example indicates restarting Apache at every night.

45 4, 10, 22 **/usr/local/etc/rc. d/Lighttpd restart
The preceding example indicates that Apache is restarted at on the 1st, 10th, and 22th every month.

10 1 ** 6, 0/usr/local/etc/rc. d/Lighttpd restart
The preceding example indicates that Apache is restarted at every Saturday and Sunday.

0, 30 18-23 ***/usr/local/etc/rc. d/Lighttpd restart
The preceding example indicates that Apache is restarted every 30 minutes between and every day.

0 23 ** 6/usr/local/etc/rc. d/Lighttpd restart
The preceding example indicates that Apache is restarted at every Saturday.

**/1 ***/usr/local/etc/rc. d/Lighttpd restart
Restart Apache every hour

* 23-7/1 ***/usr/local/etc/rc. d/Lighttpd restart
Restart Apache every hour between PM and PM.

0 11 4 * Mon-wed/usr/local/etc/rc. d/Lighttpd restart
Restart Apache on November 4 and every Monday to Wednesday.

0 4 1 Jan */usr/local/etc/rc. d/Lighttpd restart
Restart Apache at on January 1, January 1

*/30 */usr/sbin/ntpdate 210.72.145.44
Synchronization time every half hour

Related Article

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.