In the crontab file created by the user, each line represents a task, each field of each row represents a setting, its format is divided into six fields, the first five is the time setting segment, and the sixth paragraph is the command segment to execute, in the following format:
Minute hour day Month Week command
which
Minute: Represents minutes, which can be any integer from 0 to 59.
Hour: Represents the hour, which can be any integer from 0 to 23.
Day: Represents a date, which can be any integer from 1 to 31.
Month: Represents the month, which can be any integer from 1 to 12.
Week: Represents the day of the week, which can be any integer from 0 to 7, where 0 or 7 represents Sunday.
Command: The commands to execute can be either system commands or script files that you write yourself.
In each of these fields, you can also use the following special characters:
Asterisk (*): represents all possible values, such as the month field if it is an asterisk, the command action is executed monthly after the constraints of other fields are met.
Comma (,): You can specify a list range with a comma-separated value, for example, "1,2,5,7,8,9"
Middle Bar (-): An integer range can be represented by a middle bar between integers, such as "2-6" for "2,3,4,5,6"
Forward slash (/): You can specify the interval frequency of the time with a forward slash, such as "0-23/2", which is performed every two hours. A forward slash can be used with asterisks, such as */10, if used in the minute field, which means that it executes every 10 minutes.
Cron finds the configuration file in 3 places:
1,/var/spool/cron/This directory is stored in each user including root crontab task, each task is named after the creator, such as Tom built crontab task corresponding to the file is/var/spool/cron/tom. Generally, a user has only one crontab file at most.
2./etc/crontab This file is responsible for arranging the maintenance system and other tasks crontab by the system administrator.
3./etc/cron.d/This directory is used to store any crontab files or scripts to be executed.
User Permissions File:
File:/etc/cron.deny, the user listed in the file is not allowed to use the crontab command
File:/etc/cron.allow, the user listed in this file is allowed to use the crontab command
File:/var/spool/cron/, directory where all user crontab files are stored, named after user name
crontab command Explanation
1. Command format:
crontab [-u user] [-e |-l |-r]
2. Command parameters:
-u User: Used to set a user's crontab service, for example, "-u ixdba" means to set IXDBA user's crontab service, this parameter is usually run by the root user.
-E: Edits the contents of a user's crontab file. If you do not specify a user, the crontab file for the current user is edited.
-L: Displays the contents of a user's crontab file, or displays the contents of the current user's crontab file if no user is specified.
-r: Deletes a user's crontab file from the/var/spool/cron directory and, if no user is specified, deletes the current user's crontab file by default.
-I: Give a confirmation prompt when deleting a user's crontab file.
LINUX Note-crontab command