Linux Summary two: mission planning

Source: Internet
Author: User

The cron service is often encountered during routine system management, and it is used to perform a recurring task; The Cron service is a service that runs uninterrupted, and he has a anacron service, which is a cron supplement. The ability to implement a task that has not been performed in the past due to other reasons in the system has returned to normal again.

Cron classification

system Cron

/etc/crontab

Minutes, hours, months, and weeks. Tasks performed by user


User cron

/var/spool/cron/username

Tasks performed on a minute-hour-month-day

Time value

Minutes: 0-59

Hours: 0-23

Days: 1-31

Month: 1-12

Week: 0-7,0,7 all said Sunday

Time pass means "*": indicates all valid values for the corresponding


Time represents a case

1. The third point per hour

3 * * * command

2. The third minute of every Sunday hour

3 * * * 7 command

3.12:13 minutes per day

* * command

4. Discrete point of time, separated by comma min [,]

10th 40 minutes per hour, every 30 minutes of execution

10,40 * * * command

40 minutes per Tuesday 2:10 execution

10,40 * * 2,5 command

5. Continuous time point, denoted by [-]

Every Monday to Friday 2:10 execution

* * 1-5 command

6. How often in the corresponding value range, expressed by [/]

once every three minutes

*/3 * * * command

Executes every two hours

0 */2 * * command

Run every two days

0 0 */2 * * command

Note: The Cron Service execution command is looked up through the PATH environment variable, and if the user is not logged in, Cron cannot execute the command through the path variable, so the command in the Cron plan uses the absolute path, and the export path=/usr/lib64/is used in the script. Qt-3.3/bin:/usr/local/sbin:/usr/sbin:/sbin:/usr/local/bin:/usr/bin:/bin:/root/bin


User Cron Management

CRONTAB-E Edit Task Schedule-L View any schedule-u username manage the-r removal task schedule with a user

Example: Configure the machine every two days at 4 o'clock in the morning 30 backup once/etc/directory, backup files to the/tmp/etc/directory, file names such as: etc-2012-06-20.tar.bz2

[Email protected] ~]# crontab-l30 */2 * */BIN/TAR-CJF etc-' date +%y-%m-%d '. tar.bz2/etc/


This article is from "Eagle" blog, please be sure to keep this source http://seneagle.blog.51cto.com/1319845/1717918

Linux Summary two: mission planning

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.