1 Introduction
crontab file meaning :
crontab file created by the user, each row represents a task, each field representing each row of a setting, its format is divided into six fields, set the time period is the period of the first five, the sixth paragraph is command section to be executed in the following format:
Open the file (vi / etc / crontab) you will see the following:
The first four lines are used to configure the environment variables to run crond task
The first line SHELL variable specifies the system which shell to use, here is bash
The second line specifies the path to the PATH variable command system to perform
The third line MAILTO variable specifies the crond task execution information will be sent via e-mail to the root user
If the MAILTO variable is empty, it means not to send information to the user task execution
HOME variable fourth line specifies the home directory to use when executing commands or scripts.
An asterisk (*): On behalf of all possible values, such as the month field is an asterisk, it indicates that the command is executed operation after a month constraints to meet other fields.
Comma (,): a comma-separated values can be used to specify a list of ranges, e.g., "1,2,5,7,8,9"
The bar (-): can represent an integer in the range of a bar between the integer, e.g., "2-6" indicates "2,3,4,5,6"
Forward slash (/): n frequency intervals can slash specified time, for example, "0-23 / 2" is performed once every two hours.
Summary:
representation of the number 2 best to use Arabic numerals display
week and day is best not to use
a scheduled task to add annotations
can be directed to a log file or empty file
regular tasks must be an absolute path, and the directory must exist before the results
crontab Service be sure to open the run
2. Detailed
crontab: daemon regular tasks to the nearest minute, designs seconds we generally write the script -> Alarm equivalent to
a log file: ll / var / log / cron *
Edit the file: vim / etc / crontab
process: ps -ef | grep crond ==> /etc/init.d/crond restart
role: regular backup, real-time backup
Common command parameters
1 2 3 4 5 6 7 8 |
|
Cron job classification
Task scheduling of Linux into two categories, task scheduling system and user tasks scheduling.
Task scheduling system: the system work to be performed periodically, such as writing data to the hard disk cache, log clean-up.
In the / etc / crontab file, this is the task scheduling system configuration files.
User task scheduling: Users work to be performed on a regular basis, such as user data backup, regular e-mail reminders.
Users can use the tools to customize their own crontab scheduled tasks.
In crontab files are stored in / var / spool / cron directory. Consistent with its file name and user name
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
|