Timed Task crontab Command detailed

Source: Internet
Author: User

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

1 Crontab-e
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:

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.