Install crontab:

yum install crontabs

explain:

Check whether the crontab service has been set to boot. Execute the command: ntsysv, or chkconifig -- list | grep cron

Add automatic startup after startup:

1. Edit Command

 1) . On the command line, enter crontab - e, add the corresponding task, and then save and exit 2) . Edit the/etc/crontab file directly, that is, vi/etc/crontab, and add the corresponding tasks

2. File format

 Minute Hour Day Month DayofWeek CommandPath

3. Parameter Description

 Minute: the minute of every hour to execute the task; Value range 0-59 Hour: the hour of the day when the task is executed; Value range 0-23 Day: the day of each month to execute the task; Value range 1-31 Month: the month of each year to execute the task; Value range 1-12 DayOfWeek: the day of the week when the task is executed; The value range is 0-6. 0 means weekend CommandPath: Specify the program path to execute

4. Time format

 *: indicates any time; If hour bit *, it means every hour n: Indicates a specific time; For example, hour bit 5 means 5 hours n. M: specific moments; For example, hour bits 1, 10 indicate 1 hour and 10 hour N-m: a time period; For example, hour bits 1-5 are from 1:00 to 5:00 */N: indicates how many time units to execute once; For example, the hour bit */1 means that the command is executed every 1 hour. It can also be written as 1-23/1

5. Scheduling example

 *1 * * */opt/script/backup.sh: Execute every 1 minute from 1:0 to 1:59 15 05 * * */opt/script/backup. sh: 05:15 Execute */10 * * * */opt/script/backup.sh: Execute every 10 minutes 0 17 * * 1/opt/script/backup.sh: Execute every Monday at 17:00 2 8-20/3 * * */opt/script/backup. sh: 8:02,11:02,14:02,17:02,20:02 Execute

Practical examples
Some examples of crontab files:

 30 21 * * */etc/init.d/nginx restart//Restart nginx at 21:30 every night. 45 4, 1,10,22 * */etc/init.d/nginx restart//Restart nginx at 4:45 on the 1st, 10th, and 22nd of each month. 10 1 * * 6,0/etc/init.d/nginx restart//Restart nginx every Saturday and Sunday at 1:10. 0,30 18-23 * * */etc/init.d/nginx restart//Restart nginx every 30 minutes between 18:00 and 23:00 every day. 0 23 * * 6/etc/init.d/nginx restart//Restart nginx every Saturday at 11:00 pm. **/1 * * */etc/init.d/nginx restart//Restart nginx every hour *23-7/1 * * */etc/init.d/nginx restart//Restart nginx every hour between 11:00 p.m. and 7:00 a.m 0 11 4 * mon wed/etc/init.d/nginx restart//Restart nginx on the 4th of each month and at 11:00 from Monday to Wednesday 0 4 1 jan */etc/init.d/nginx restart//Start nginx at 4:00 on January 1 */30 * * * */usr/sbin/ntpdate 210.72.145.20//Synchronize the time every half an hour