Need to write a regular update system under Linux script, man Crondtab is not very detailed, now the network is listed as follows:
Crontab is a handy program that performs a task periodically (looping) on a unix/linux system using the cron service, viewing the Cron service status with service Crond status, and if not started, service Crond start starts it, The cron service is a timed execution service that can be added or edited with the crontab command to perform tasks that need to be timed:
Crontab-u//Set a user's Cron service, which is usually required by the root user when executing this command
CRONTAB-L//list details of a user cron service
Crontab-r//Delete a cron service with no users
CRONTAB-E//Edit a user's cron service
For example, root to view your cron settings: Crontab-u root-l
Again, for example, Root wants to delete Fred's cron settings: Crontab-u fred-r
When editing the Cron service, the edited content has some formatting and conventions, input: Crontab-u root-e
Enter VI edit mode, the content of the edits must conform to the following format: */1 * * * * ls >>/tmp/ls.txt
Edit the/etc/crontab file and add a line at the end: 5 * * * Root init 6 This configures the system to automatically restart every morning at 5 o ' 30.
You need to set Crond as a service that starts automatically after system startup, and in/etc/rc.d/rc.local, at the end, add
Service Crond Start
If you also need to load additional services on the system boot Ten, you can continue to add the start command for other services.
For example: Service mysqld start
Basic usage:
1. Crontab-l
List the current crontab tasks
2. crontab-d
Delete the current crontab task
3. CRONTAB-E (solaris5.8 above is crontab-r)
Edit a crontab task, Ctrl_d end
4. crontab filename
A task list file that is crontab as filename and loaded into
Format of crontab file:
The rows in the crontab file consist of 6 fields separated by a space or TAB key between the different fields. First 5 fields specify when the command will run
Minutes (0-59)
Hours (0-23)
Date (1-31)
Month (1-12)
Day of the week (0-6, of which 0 stands for Sunday)
The 6th field is a string to be executed at the appropriate time
Example:
#MIN HOUR Day MONTH DAYOFWEEK COMMAND
#每天早上6点10分
6 * * * Date
#每两个小时
0 */2 * * * DATE (Solaris 5.8 does not seem to support this type of notation)
#晚上11点到早上8点之间每两个小时, 8 in the morning.
0 23-7/2,8 * * * Date
#每个月的4号和每个礼拜的礼拜一到礼拜三的早上11点
0 4 * mon-wed date
#1月份日早上4点
0 4 1 Jan * Date
Crond Service and crontab usage in Linux