Article from: http://www.centoscn.com/CentOS/help/2014/1030/4025.html
Objective
Crontab is used by UNIX and Linux to set up periodically executed instructions, is the Internet is very common technology, many tasks will be set up in the crontab loop execution, if not the use of crontab, then the task is resident program, which for your program requirements are relatively high, A program that requires you to be in 24x7 hours, one is to ask your scheduler more reliable, the actual work, 90% of the program does not need to spend so much time and energy to solve the above two problems, just write their own business logic, through crond this industrial-level program to dispatch on the line, Crond reliability, robustness, we should be no doubt.
Crontab easy to get started
Let's say I want to set a task, do a data synchronization every minute, the path of this synchronization script is/home/blue/do/rsyncfile.sh, then I can configure it, use the blue user, in the terminal input
2 |
# At this time will enter the VI edit screen to let you edit the work. Note that each job is a single line. |
3 |
|<============== the full command line of the task at the time of the #分 |
4 |
* * * * */home/blue/do/rsyncfile.sh * * * |
By default, any user who is not included in the/etc/cron.deny will be able to directly release "Crontab-e" to edit his or her routine commands. The whole process as mentioned above, will enter the vi edit screen, and then a work line to edit, edited after the input ": Wq" after the storage to leave VI on it.
If we need to modify a script that runs data synchronization every 5 minutes, then use CRONTAB-E to enter the edit:
1 |
*/5 * * * */home/blue/do/rsyncfile.sh |
If the server out of the question, one day the data is not synchronized, so we need to fill the data, assuming that the complement of the data script is/home/blue/do/rsyncfile_day.sh, but the daytime is the peak, evening users are not much, is a low peak period, we fill the data will occupy a lot of bandwidth, Especially during the daytime, will affect the normal business, so generally we can let the supplementary data task start at 2 o'clock in the morning, then also use CRONTAB-E to enter the editor: