Understanding of Linux Crond timing tasks

Understanding of Linux Crond timing tasks

Crond is a service or software used in the system to periodically execute commands or specify program tasks . Strictly speaking, there are a lot of timed task software under the linux system, such as: at , crontab , anacron , among which the crontab command is often used to execute tasks periodically in actual work . For example: do a server time synchronization every five minutes. To execute the crontab command, you also need to start a service crond . So, let's practice crontab . 

 

1. Speak the meaning of the text according to the command :

1)30 3,12 * /bin/sh  /scripts/oldboy.sh

In this example, the first column is 30 , which means 30 minutes ; the second column is 3 o'clock and 12 o'clock, this timed task means every day at 3:00 a.m. 30) Execute the /scripts/oldboy.sh script

2)30 */6 * * * /bin/sh /scripts/oldboy.sh

In this example, the first column is 30, which means 30 minutes, and the second column is */6, which means every 6 hours. 30, 18:30, 24:30) execute the /scripts/oldboy.sh script

3)30 8-18/2 * * * /bin/sh /scripts/oldboy.sh

In this example, the first column is 30, which means 30 minutes, and the second column is 8-18/2, which means every 2 minutes between 8:00 am and 18:00 pm

Hours, this timed task means to execute the /scripts/oldboy.sh script every 2 hours between 8:00 am and 18:00 pm

4)30 21 * * * /application/apache/bin/apachectl graceful

Indicates that Apache is restarted at 21:30 every night

5)45 4 1,10,22 * * /application/apache/bin/apachectl graceful

Indicates that Apache is restarted at 4:45 am on the 1st, 10th, and 22nd of each month

6)10 1 * * 6,0 /application/apache/bin/apachectl graceful

Indicates that Apache is restarted at 1:10 am every Saturday and Sunday

7)0,30 18-23 * * * /application/apache/bin/apachectl graceful

Indicates that Apache is restarted every 30 minutes between 18:00 and 23:00 every day

8)* 23,00-07/1* * * /application/apache/bin/apachectl graceful

Indicates that Apache is restarted every minute every hour between 23:00 and 07:00 the next day

9)00 11 * 4 1-3 /application/apache/bin/apachectl graceful

Indicates that Apache is restarted at 11:00 AM every Monday to Wednesday in April

 

2. Write the timing rules according to the text description :

1) On May 5th at 9:00 am, we will go to the Old Boys training class. The rules are:

#00 09 05 05 * Go to Old Boys training class

2) Education and training for old boys in the district every Sunday at 9:30 am. The rules are:

#30 09 * * 0 Go to Old Boys Educational Training

 

The C rond service is a running program that can execute system instructions or script scripts at regular intervals through crontab. The unit of time interval can be minutes, hours, days, months, weeks, or any combination of the above (day and week should not be combined) , which is suitable for enterprise operation and maintenance scenarios such as periodic log analysis or data backup.

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326004913&siteId=291194637