Installing crontab
[email protected] ~]# Yum install Vixie-cron
[email protected] ~]# Yum install Crontabs
Description
Vixie-cron package is the main program of Cron;
The Crontabs package is a program used to install, uninstall, or list tables used to drive the cron daemon.
Use the following method to start and close the cron service:
/sbin/service Crond Start//Startup service
/sbin/service Crond stop//Shut down service
/sbin/service crond Restart//Restart service
/sbin/service Crond Reload//Reload Configuration
View crontab Service Status: Crond status
Manually Start crontab services: Service Crond start
To see if the Crontab service is set to boot, execute command: NTSYSV
Add to boot auto start:
Chkconfig–level Crond on
1. Crond service Management and access control
[Email protected] ~]# service Crond restart
[Email protected] ~]# chkconfig Crond on
2, the user's crontab settings
[Email protected] ~]# crontab [options]
Options:
-E: Editing crontab timed tasks
-L: Query crontab task
-R: Delete all crontab tasks for the current user
[Email protected] ~]# CRONTAB-E
#进入crontab编辑界面. will open vim to edit your work.
* * * * * * tasks performed
The first one "*"
The first few minutes of an hour
0-59
A second "*"
The first hours of the day
0-23
A third "*"
The first day of the one months
1-31
Fourth "*"
The first month of the year
1-12
Fifth "*"
The week of the week
0-7 (0 and 7 both represent Sunday)
3. Special Symbolic meanings
*
Represents any time. For example, the first "*" is meant to be executed every minute of the hour.
,
Represents a non-sequential time. For example, "0 8,12,16 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * command"
-
Represents a continuous time range. such as "0 5 * * 1-6 command", which represents the execution of commands from Monday to Saturday 5:0 A.M.
*/n
Represents how often it is executed. Like "*/10 * * * * * * * * * * * * * * * * * * * * * * * * * * * command"
4. Example
45 22 * * * command
Execute command at 22:45
0 17 * * 1 command
1 17:0 per week to execute commands
0 5 1,15 * * command
5:0 A.M. every month, 1th and 15th, execute orders.
40 4 * * 1-5 command
Every Monday to Friday 4:40 A.M. execute the Order
*/10 4 * * * command
Commands are executed every 10 minutes at 4 o'clock in the morning every day
0 0 1,15 * 1 command
Orders 1th and 15th per month are executed at 1 0:0 every week. Note: The day of the week and the date is best not to appear at the same time, because they define the days. Very easy for administrators to mess up.
5. For example
*/5 * * * */bin/echo "one" >>/tmp/test
5 5 * * 2/sbin/shutdown-r now
0 5 1,10,15 * */root/sh/autobak.sh
This article from "Mountain" blog, declined reprint!
Linux CentOS6.3 install Crond Timer service and set scheduled tasks