Linux task scheduling
People do not arrange, called fooling around. We often will set some of their own programs, set alarms to remind yourself. In the data backup, data backup often in uncertain times, it may be a few early morning, if the morning to get up to open the computer to back up data, it is clearly unrealistic. linux provides task scheduling.
Outline
A specific command or program the system at a time to perform: task scheduling.
Basic instructions
crontab [选项]
- Common options
Options | description |
---|---|
-e | Edit crontab regular tasks |
-l | Query crontab task |
-r | Delete all current users crontab tasks |
service crond restart
: Restart service scheduling
Base case
*/1**** date >>/home/linux/text.txt
- Placeholder
project | meaning | range |
---|---|---|
First"*" | Among the first few minutes of one hour | 0-59 |
the second"*" | The first few hours of the day | 0-23 |
The third"*" | The first day of the month among the | 1-31 |
the fourth"*" | The first few months of the year | 1-12 |
the fifth"*" | The week of the week | 0-7 (0 and 7 represent Sunday) |
- Special symbols
Special symbols | meaning |
---|---|
* | Representatives at any time. For example, the first "*" represents one hour are executed once per minute. |
, | On behalf of discontinuous time. For example, "0 8, 12, 16 * * * Commands", on behalf of the day 8:00, 12:00, 16:00 command is executed once |
- | It represents the continuous time frame. For example, "05 * * 1-6 command", representing execute commands Monday to Saturday, 5:00 |
*/n | Representative of how often executed once. Such as "* / 10 * * * * Commands", on behalf of every 10 minutes to perform a command. |
- Case
time | meaning |
---|---|
4522 * * * command | Run at 22:45 |
* 017 * 1 command | The weekly 17:00 Run |
05 1,15 * * command | 1 and 15 of each month 5:00 Run |
404 * * 1-5 Command | Monday to Friday 4:40 perform a command |
* / 104 * * * command | 4:00 per day, once every 10 minutes execute command |
0 0 1,15 * 1 command | No. 1 and No. 15 monthly, weekly 10:00 command will be executed. Note: The best day of the week and a few numbers do not appear at the same time, because they are the days defined. Very easy for administrators confused. |