The scheduled task--crontab__linux under Linux

Source: Internet
Author: User

Cron is a daemon under Linux that is used to perform tasks on a regular basis.

To allow Cron to perform the tasks you specify, you first need to edit the crontab file.

Command: CRONTAB-E

Just go in to hint select an editor, optional, I used to use VIM

You can write tasks that you want to perform periodically in this area.

The format is this:

One line for each job, a total of six fields. In addition, there are some auxiliary characters:

I wrote a regular task for the test,

*/2 * * * Date >> ~/time.log

It means that the date >> ~/time.log command (log the current time to the Time.log file) is executed every two minutes. You can add it to your crontab and then save the exit.

After saving the crontab, we also need to restart Cron to apply this scheduled task. Using commands: sudo service cron restart just OK.

Other examples:

* * * * * * * * * Every minute of the task (min.) 0 * * * * * * * * * * * * * * * 0 points per hour, such as 6:00,10:00 6,10 * 2 * # 2nd per month, 6 minutes and 10 minutes per hour. Perform a task */3,*/5 * * * * * * * * every 3 minutes or 5 minutes, such as 10:03,10:05,10:06

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.