Following the last scheduled backup of the site data, this time to say Crontab the use of timed execution tools.
Installation of 1.Crontab
Installation commands under Ubuntu:
Apt-get Install cron
Reboot crontab:
/etc/init.d/cron restart
2.Crontab Use method
View Crontab Scheduled Tasks list:
Crontab-l
Add crontab timed to perform tasks:
Crontab-e
When you add a timed task, you may be able to crontab the default editor, by default, the Nano editor is recommended, the use is simpler, directly at the end of the file, press crontab command format input, ctrl+x exit, and then enter Y to save.
Another is the VI editor, first press I key, at the end of the file according to crontab command format input, and then press ESC, and then enter: Wq return.
After you add a timed task, you need to reboot the crontab
3.crontab Task Command writing format
Format: Minute hour dayofmonth month DayOfWeek command
Explanation: Minute hour date month pay week order
Range: 0-59 0~23 1~31 1~12 0~7,0 and 7 both represent Sundays
In crontab we will often use the *, –/n these 4 symbols, well, or to draw a table, more clearly:
Symbolic interpretation
* (asterisk) represents all valid values. For example, 0 * * * Backup executes the backup command regardless of the number of months and weeks of the week, 23 o'clock.
, (comma) represents splitting multiple values. such as: 9 1,16,20 * * Command every month 1, 16, 20th, the command order is executed 9:30.
-(minus) represents a time range. such as 0 9-17 * * * * checkmail every day from 9 o'clock to 17 o ' Hour to execute checkmail command
/n represents a long interval of time. */5 * * * * Check commands are executed every 5 minutes, as in the case of 0-59/5.
Here are some examples to deepen the understanding:
Daily 3:00 Backup Program: 0 3 * * */root/backup.sh
Log cleanup is performed every Sunday 8:30:8 * * 7/root/clear.sh
1 weeks 5 0 o'clock per week execution test procedure: 0 0 * * 1,5 test
Every May 12 14 o'clock execution of the Wenchuan procedure: 0 5 */root/wenchuan
Restart every 15 minutes from 18 o'clock in the evening to 23 o ' PHP-FPM:*/15 18-23 * * * */ETC/INIT.D/PHP-FPM