In the O & M industry, there is a popular saying that it can be automatically completed without manual operations. This involves setting crond for scheduled tasks in Linux. The following describes how to set crond.
Method 1: edit/etc/crontab
SHELL =/bin/bash
PATH =/sbin:/bin:/usr/sbin:/usr/bin
MAILTO = root
HOME =/
# For details see man 4 crontabs
# Example of job definition:
#. ---------------- Minute (0-59)
# |. ----------- Hour (0-23)
# |. ---------- Day of month (1-31)
# |. ------- Month (1-12) OR jan, feb, mar, apr...
# |. ---- Day of week (0-6) (Sunday = 0 or 7) OR sun, mon, tue, wed, thu, fri, sat
# |
# ***** Command to be executed
Format description:
1st columns minute 1 ~ 59
2nd columns hour 1 ~ 23 (0 indicates midnight)
3rd columns daily 1 ~ 31
4th columns Month 1 ~ 12
5th columns in a week 0 ~ 6 (0 indicates Sunday)
6th columns of commands to run
Example:
01 ***** ntpdate time.windows.com
The preceding example indicates that the system time is synchronized every hour.
59 23 ***/etc/init. d/httpd restart
The preceding example indicates restarting apache at every night.
45 4 1 **/etc/init. d/httpd restart
The preceding example indicates restarting apache at on the first day of every month.
45 4, 10, 22 **/etc/init. d/httpd restart
The preceding example indicates that apache is restarted at on the 1st, 10th, and 22th every month.
10 1 ** 6, 0/usr/local/apache/bin/apachectl restart
The preceding example indicates that apache is restarted at every Saturday and Sunday.
0, 30 18-23 ***/usr/local/apache/bin/apachectl restart
The preceding example indicates that apache is restarted every 30 minutes between and every day.
0 23 ** 6/usr/local/apache/bin/apachectl restart
The preceding example indicates that apache is restarted at every Saturday.
**/1 ***/usr/local/apache/bin/apachectl restart
Restart apache every hour
* 23-7/1 ***/usr/local/apache/bin/apachectl restart
Restart apache every hour between PM and PM.
0 11 4 * mon-wed/usr/local/apache/bin/apachectl restart
Restart apache on November 4 and every Monday to Wednesday.
0 4 1 jan */etc/init. d/httpd restart
Restart apache at on January 1, January 1
Method 2: crontab-e
Usage: crontab [-u user] file
Crontab [-u user] [-e |-l |-r]
(Default operation is replace, per 1003.2)
-E (edit user's crontab)
-L (list user's crontab)
-R (delete user's crontab)
-I (prompt before deleting user's crontab)
-S (selinux context)
The parameter is very simple. I believe you will understand these words at first glance. The format is the same as that described in method 1. It should be noted that crontab-e writes your own scheduled tasks, files are stored in the following directory:
/Var/spool/cron/
In Linux, Crond, scp, and tar are used in combination with automatic backup.
Crond command in Linux
Installing the Crond service in CentOS
Crond service and crontab usage in Linux
Crond resident command for Task Scheduling in Linux
In Linux, use Crond and regular CT to log on to the switch regularly to execute tasks.