Crontab
Recurring time schedule tasks, time is over and not executed, to the next cycle
/etc/init.d/crond Start Open Crond Service
Vim/etc/crontab crontab configuration file
* * * * * Root run-parts/etc/cron.hourly
4 * * * Root run-parts/etc/cron.daily
4 * * 0 root run-parts/etc/cron.weekly
4 1 * * Root run-parts/etc/cron.monthly
First field: minutes, value range 0 to 59
Second field: Hours, value range 0 to 24
Third field: day, value range specific month
Fourth field: month, value range 1 to 12
Fifth field: Week, value range 0 to 7, 0 and 7 for Sunday
Sixth field: The identity of the performing task
The seventh field: the command to execute, multiple commands separated by semicolons, enclosed in parentheses;
The run-parts definition is followed by a directory, which must be followed by a directory path, representing all scripts running in this directory
Time format
* represents every minute, hourly, daily, monthly, weekly
, the comma represents the separation time
-Representative time period
/n stands for every n units
Cases:
Perform tasks in the first 30 minutes of each hour
1-30 * * * *
Every hour the 29th, 58 minutes to execute
29,58 * * * *
Executes every 2 minutes
*/2 * * * *
15th per month, every three hours, every two minutes, perform tasks.
*/2 */3 15 * *
15th per month, every three hours, every two minutes, perform tasks or seven every three hours per week, every two minutes.
*/2 */3 15 * 7
Practice:
05 points per day of the 1,3,7,8,13,21 point of execution
Every month, from 5th to 20th, from 4 to 13, 15 points.
Every two hours of every Wednesday
5-8 months of the Wednesday and Sunday of the year of 4:01 execution
Cases:
Vim/etc/crontab
* * * * * * root echo ' Hello ' >/DEV/PTS/2
Save exit, do not need to restart the service, to ensure that the service is the start state, every minute our second terminal will receive a Hello
CRONTAB-E Set your own time task
* * * * init 0 shut down at 21 points per day
Crontab-l to view your time tasks
Crontab-l-U root view time task for root user
CRONTAB-E-U root Edit the time task of the root user
Crontab-r Delete the current user all time task
Crontab-i Request Confirmation before deleting
/etc/cron.allow allows the use of Crond's ordinary user name, there is no need to consider this file Cron.deny
/etc/cron.deny deny use of Crond's normal user name
Linux Scheduled Tasks