CentOS timed start and purge tasks

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.