Linux-ubuntu-crontab

Source: Internet
Author: User

  1. To open the Crontab task plan:

    1. Select the Crontab file editor to edit the crontab file:

      Results:

      Select an editor. To change later, run ' Select-editor '.
      1./bin/ed
      2./bin/nano <----easiest
      3./usr/bin/vim.basic
      4./usr/bin/vim.tiny

      Choose 1-4 [2]: 3 (VIM editor)


    2. Edit crontab File: command:~# crontab-e

      1. The use of this command is relatively straightforward. Direct input

      2. ~# CRONTAB-E

        An edit window opens, and the first line is prompted with the content format:

      3. # m H Dom Mon Dow command
        The specific meaning is: the minute-hour date month-week command , the day of the month (Mon) or the days of the week (h,24-hour) several (m) execution of a command,* denotes any time. For example:

      4. 3 * * * */home/meng/hello.sh

      5. is: The hello.sh script under/home/meng/is executed at 03 o'clock every hour.

      6. After saving, according to the following screen prompts to enter Ctrl+x exit, you will be prompted to save, enter Y; prompt for the file name, and a temporary file name, because just test, direct carriage to save.

      7. Note: To restart the cron process after editing is complete:

        1. ~#/etc/init.d/cron Restart (not available for Ubuntu)

        2. #sudo Service cron Restart (available with Ubuntu)

      8. Here's a little explanation of the meaning of each line in crontab. Each row in crontab represents a task that is performed on a regular basis and is divided into 6 parts. The first 5 sections indicate when to execute the command, and the last part represents the command to execute. Each part is separated by a space, except that the last part (the command) can use a space inside it, and no space in the other part. The first 5 sections represent: minutes, hours, days, months, and weeks, with the following values for each part:


    1. Minutes 0-59

    2. Hours 0-23

    3. Day 1-31

    4. Month 1-12

    5. Week 0-6 0 indicates Sunday

    6. In addition to these fixed values, you can also match the asterisk (*), comma (,), and slash (/) to indicate some other meanings:

      1. Asterisks indicate any value, such as filling in the hour section * for any hour (per hour)

      2. Commas can allow multiple values to be filled in a section, such as filling in minutes with 1,3 for one minute or three minutes

      3. The slash general mate * is used, representing how often, for example in the hour section fill in the */2 representative every two minutes. So there is no difference between */1 and * */2 can be seen as an arbitrary value that can be divisible by 2.

  1. * * * * * # Perform a task every minute

  2. 0 * * * * # 0 points per hour to perform a task, such as 6:xx

  3. 6,ten * 2 * * # 2 per month, 6 minutes per hour and ten minutes to perform a task

  4. */3, */ 5 * * * * * every 3 minutes or 5 minutes to perform a task, forexample:0 5,ten:

This article is from the "Mr_computer" blog, make sure to keep this source http://caochun.blog.51cto.com/4497308/1638886

Linux-ubuntu-crontab

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.