Crontab command details

Source: Internet
Author: User

Author: aolinks

The crontab command schedules the execution of some commands at certain intervals. There is a crontab file in the/etc directory, which stores some scheduling programs that are running systematically. Each user can create their own scheduling crontab.

The crontab command has three forms of command line structure:

Crontab [-u user] [file]

Crontab [-u user] [-e |-l |-r]

Crontab-l-u [-e |-l |-r] In the first command line, file is the name of the command file. If this file is specified in the command line, run the crontab command to copy the file to the crontabs directory. If this file is not specified in the command line, the crontab command will accept the commands typed on the standard input (keyboard) and store them in the crontab directory.

In the command line, the-r option is used to delete the crontab file from the/usr/spool/cron/crontabs directory;

In the command line, the-l option is used to display the contents of the crontab file.

Run the crontab-u user-e command to edit the cron (c) job of the user. You can edit a file to add or modify any job requests.

Run the crontab-u user-r command to delete all cron jobs of the current user.

Jobs and their scheduled time are stored in the file/usr/spool/cron/crontabs/username. Username stores the user name in the corresponding file with the command that the user wants to run. The command execution result, whether it is standard output or error output, will be sent to the user in the form of mail. Each request in the file must contain six fields separated by spaces and tabs. The first five fields can take an integer to specify when to start working. The sixth field is a string called a command field, which includes the crontab command for scheduling and execution.

The value range and significance of the integer in the first and fifth fields are as follows:

0 ~ 59 indicates the score

1 ~ 23 indicates the hour

1 ~ 31 indicates the day

1 ~ 12 indicates the month.

0 ~ 6 indicates the week (0 indicates Sunday)

/Usr/lib/cron. allow indicates who can use the crontab command. If it is an empty file, it indicates that no user can schedule a job. If this file does not exist and another file/usr/lib/cron. deny exists, the crontab command can be used only by users not included in this file. If it is an empty file, it indicates that any user can arrange jobs. If both files exist at the same time, cron. allow takes priority. If neither of them exists, only the Super User can schedule a job.

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.