Scheduled tasks are divided into 2 species:
1. Exceptions: Perform the work according to a certain cycle, such as monthly salary, daily work report, daily need of punch, etc.
2. Temporary: Specify the time to execute the order, this time do not have to do next time, such as girlfriend's birthday, leadership inspection work, etc.;
The work of these scheduled tasks Linux can also help us, for example: Every day early 6 : 00 before work email
for recurring tasks, use Cron order;
for temporary tasks, use at order;
at Command: Executes the specified command at a specified time, and then cancels the command from the system after execution;
Cron Command: Executes the specified command periodically at a specified time;
installation crontab :
Yum Install Crontabs
Description
/etc/init.d/crond Start Start the service
/etc/init.d/crond Stop Close Service
/etc/init.d/crond Restart Restart Service
/etc/init.d/crond Reload Reload Configuration
View crontab Service Status: /etc/init.d/crondd Status
View crontab If the service is set to boot, execute the command: Ntsysv
add to boot: chkconfig–level Crond on
1. crontab command
function Description: Setting Timers
Syntax: crontab [-u < user name >][ config file ] or crontab [-u < user name >][-ELR]
Additional notes: Cron is a resident service that provides the function of a timer that allows the user to execute a preset instruction or program at a specific time, and the function of the timer can be used as long as the user edits the timer's configuration file ;
Its configuration file format is as follows:
Minute Hour Day Month DayOFWeek Command
Parameters:
- e Edit the user's timer settings;
- L lists the user's timer settings;
- R Delete the user's timer settings;
-u< User name > Specifies the name of the user to set the timer;
2. crontab format
Basic format: * * * * * command
points when Day Month Week Command
The 1th column represents: Minutes 1~~59 per minute with * or */1
The 2nd column indicates: Hour 1~~23 (0 means 0 points)
The 3rd column represents: Date 1~~31
The 4th column indicates: Month 1~~12
The 5th column represents: Week 0~~6 (0 = Sunday)
The 6th column represents: Run command
650) this.width=650; "title=" crontab format diagram. jpg "src=" http://s3.51cto.com/wyfs02/M01/58/6C/wKioL1Svlc_ R1y2naagydov6z7a969.jpg "alt=" Wkiol1svlc_r1y2naagydov6z7a969.jpg "/>
3. Case
* * * * * /etc/init.d/nginx Restart restart Nginx every 21:30
45 4 1 ,10,22 * */etc/init.d/nginx restart 1, 10, 22nd 4:45 minutes restart Nginx
10 1 * * 6 ,0/etc/init.d/nginx restart 1:10 Restart Nginx per week, 6th
0,30 18-23 * * */etc/init.d/nginx restart point to 23 to restart Nginx
every 30 minutes
0 * * 6/etc/init.d/nginx restart Restart Nginx
at 23 points per Saturday
* */1 * * */etc/init.d/nginx restart Restart Nginx
every hour
* 23-7/1 * * */etc/init.d/nginx restart 23 o'clock to 7 a.m., restart Nginx
every hour
0 4 * Mon-wed/etc/init.d/nginx restart Monday to Wednesday 11 o'clock, 4th/month restart Nginx
0 4 1 Jan */etc/init.d/nginx restart 4-point restart of nginx on January 1
*/30 * * * * /usr/sbin/ntpdate 210.72.145.20 synchronize time every 30 minutes
This article is from the "rely on some numbers" blog, please be sure to keep this source http://liubao0312.blog.51cto.com/2213529/1601293
Crontab Timing Task Detailed