12.1 Overview
Task scheduling: refers to a specific command or program that the system executes at a certain time.
Task scheduling classification:
1. System work: Some important work must be performed over and over again, such as virus scanning.
2. Individual user work: Individual users may wish to perform certain procedures, such as backup of the mysql database.
12.2 Basic syntax
crontab [options]
Common options:
-e Edit crontab to set task schedule
-l List which tasks are currently scheduled
-r delete all task schedules of the current user
service crontab restart restart task scheduling
12.3 Quick Start
1. Set up personal scheduling tasks, that is, edit the task scheduling file /etc/crontab. Execute the crontab -e command.
2. Then enter the task into the schedule file
It means to execute ls -l /etc > /tmp/ha.txt every minute
There is no ha.txt file at the time of 09 minutes
At 10 minutes there will be a ha.txt file
12.4 Description of the 5 placeholders
12.5 Description of special symbols
12.6 Cases of task execution at a specific time
12.7 Case: Append the current date and calendar to the /home/mycal file every 1 minute
1. First write a file /home/mytask.sh
2. Give mytask.sh an executable permission
3. Edit the task scheduling file /etc/crontab
4. Success
with