The Crond command in Linux

Source: Internet
Author: User

Crond is a command that Linux uses to execute programs on a regular basis. This task dispatch command is started by default when the operating system is installed. The Crond command periodically checks to see if there is any work to be done and the work will be performed automatically if there is work to be done. Linux task scheduling is mainly divided into the following two categories:

1, the system performs the work: the system periodically to perform the work, such as the backup system data, cleans up the cache

2, Personal work: a user to do regular work, such as every 10 minutes to check the mail server for new letters, the work can be set by each user

Crontab is a timed task trigger under the UNIX system, with the user's permissions recorded in the following two files:

File meaning

/etc/cron.deny users listed in this file are not allowed to use the crontab command

/etc/cron.allow users listed in this file are allowed to use the crontab command

/var/spool/cron/is a crontab file for all users

/var/spool/cron/crontabs/var/spool/cron/crontabs

The format of the crontab command is: crontab–l|-r|-e|-i [username], which has the following parameter meanings as table one:

Parameter name www.britepic.org Example of meaning

-L Displays the contents of the user's crontab file crontabl–l

-I give prompt before deleting user's crontab file Crontabl-ri

-R Remove the user's crontab file from the crontab directory Crontabl-r

-e Edit user's crontab file crontabl-e

The crontab file created by the user is stored in/var/spool/cron with the same file name as the user name.

Its format is divided into six paragraphs, the first five paragraphs is the time set paragraph, the sixth paragraph is to execute the command section,

The format is as follows: * * * * *

The meaning of its time period is as Table II:

Value range of paragraph meaning

The first paragraph represents the minute 0-59

The second paragraph represents the hour 0-23

The third paragraph represents the date 1-31

The fourth paragraph represents the month 1-12

The fifth paragraph represents the day of the week, 0 represents Sunday 0-6

Example: If the content of the user's crontab file is: * * * * echo its dinner time, the system displays ' its dinner time ' in 19:29 per day

Let's take a look at a few specific examples:

0 */2 * * */sbin/service httpd restart means to reboot Apache every two hours

7 * * */sbin/service sshd start means SSH service is opened 7:50 every day

* * * */sbin/service sshd stop means the SSH service is closed 22:50 every day

0 0 1,15 * * fsck/home monthly 1th and 15th check/home disk

1 * * * */home/bruce/backup the first minute of every hour to execute/home/bruce/backup this file

* * 1-5 find/home "*.xxx"-mtime 4-exec rm {} \; Every Monday to Friday 3 o'clock, in the directory/home, look for files with the file name *.xxx and delete the files 4 days ago.

6 */10 * ls means monthly 1, 11, 21, 31st Yes 6:30 execute the LS command


The Crond command in Linux

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.