Because of the need to perform tasks on a timed basis, we found the Crontab tool and introduced its usage:
Shell=/bin/bash path=/sbin:/bin:/usr/sbin:/usr/bin mailto=root home=/ # run-parts 01 * * * * Root run-parts/etc/cron.hourly 4 * * * Root run-parts/etc/cron.daily 4 * * 0 root Run-parts/etc/cron.week LY 4 1 * * Root run-parts/etc/cron.monthly
The second paragraph should be defined as: hours, expressed from the first hours of execution, the range is from the 0-23 third paragraph should be defined is: date, expressed from the day of the month, the scope of the fourth paragraph should be defined is: The month, the first month of the year to execute, the scope from the fifth paragraph should be defined is: weeks, Represents the day ordinal of a week, ranging from 0-6, where 0 represents Sunday. Every six paragraphs should be defined: the user name, that is, the execution of the program to be executed by which user, this can generally be omitted; The seventh paragraph should be defined as: command and arguments executed.
Method One:
Set up server timed boot
Vim/etc/crontab
#reboot set to restart 10:30 every day * * * * Root/sbin/reboot
Reload Configuration
/sbin/service Crond Reload
Restart Cron
/sbin/service Crond Restart
Method Two:
Execute directly at the command line
[[email protected] ~]# CRONTAB-E Add timing
*/10 17-18 * * * root tcpdump-i eth0 TCP port 80-s 0-w sohu1.txt
*/10 17-18 * * * root tcpdump-i eth0 TCP port 80-s 0-w sohu1.cap
Wq exit
[[email protected] ~]# Crontab-r Delete Task
[[email protected] ~]# crontab-l display tasks
For example, Tcpdump is still running in the background, you can use Killall tcpdump
CentOS timed start and purge tasks