1: install [php] viewplaincopyyuminstallvixie-cronyuminstallcronta
1: Installation
[Php]View plaincopy
- Yum install vixie-cron
- Yum install crontabs
- Chkconfig crond on // start the service
2: Description of the global configuration file (/etc/crontab)
[Php]View plaincopy
- SHELL =/bin/bash
- PATH =/sbin:/bin:/usr/sbin:/usr/bin
- MAILTO = root
- HOME =/
- # Run-parts
- 01 *** root run-parts/etc/cron. hourly
- 02 4 *** root run-parts/etc/cron. daily
- 22 4 ** 0 root run-parts/etc/cron. weekly
- 42 4 1 ** root run-parts/etc/cron. monthly
The above are all default values. To put it simply:
# Run-parts:
The first section should be defined as minute, which indicates the minute of every hour for execution. The range is from 0 to 59. The second segment should be defined as: Hour, which indicates the number of hours for execution. The range is from 0 to 23.
The third paragraph should be defined as: date, which indicates execution from the day of each month, range from 1-31
The fourth part should be defined as month, which indicates the number of months of the year to be executed, ranging from 1 to 12.
The fifth part should be defined as Week, which indicates the day of the week for execution, ranging from 0 to 6, where 0 indicates Sunday.
The user name should be defined in each section, that is, the user in which the execution program is to be executed, which can be omitted;
Section 7 should define the commands and parameters to be executed.
01 * root run-parts/etc/cron. hourly indicates the first minute of every hour to start executing executable programs or scripts in the/etc/hourly directory;
02 4 * root run-parts/etc/cron. daily indicates that the executable program or script under the/etc/cron. daily directory is started at 04:02 every day;
2 4 ** 0 root run-parts/etc/cron. weekly...
42 4 1 ** root run-parts/etc/cron. monthly
Text:
1: Set the server to restart at a certain time
Vi/etc/crontab
[Php]View plaincopy
- # Reboot is set to restart at every day
- 30 10 * root/sbin/reboot
Remember to restart the crond service: service crond restart