Linux under crontab simple use

Source: Internet
Author: User

0. Personal tagsCaicongyangHttp://blog.csdn.net/caicongyang1.crontab

Crontab is a scheduled task under Linux, which is also available in sping

2. Basic format

* * * * * command
Time-sharing Weekly command

3. Command

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)
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 user's cron service
crontab–e//Edit a user's cron service
crontab filename//with filename as the crontab task list file and load
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

4. Restart

Modified crontab requires a reboot, and the following commands provide a view of the status of the crontab and the restart

#service crond status#service Crond Restart

5.

#每天早上6点10分
6 * * * Date
#每两个小时
0 */2 * * * Date
#晚上11点到早上8点之间每两个小时, 8 in the morning.
0 23-7/2,8 * * * Date
#每个月的4号和每个礼拜一到礼拜三的早上11点
0 4 * 1-3 date
#1月1日早上4点
0 4 1 1 * Date

* * * * */usr/local/etc/rc.d/lighttpd restart

The above example shows that 21:30 restarts Apache per night.

4 1,10,22 * */USR/LOCAL/ETC/RC.D/LIGHTTPD restart
The above example shows that 4:45 restarts Apache on the 1, 10, and 22nd of the month.

1 * * 6,0/USR/LOCAL/ETC/RC.D/LIGHTTPD restart
The above example shows that 1:10 restarts Apache every Saturday and Sunday.

0,30 18-23 * * */usr/local/etc/rc.d/lighttpd restart
The above example shows that Apache restarts every 30 minutes from 18:00 to 23:00 every day.

0 * * 6/USR/LOCAL/ETC/RC.D/LIGHTTPD restart
The above example shows the restart of Apache every Saturday at 11:00am.

* */1 * * * */usr/local/etc/rc.d/lighttpd restart
Restart Apache every hour

* 23-7/1 * * * */usr/local/etc/rc.d/lighttpd restart
From 11 o'clock to 7 in the morning, restart Apache every hour.

0 4 * mon-wed/usr/local/etc/rc.d/lighttpd restart
4th per month with 11-point restart from Monday to Wednesday Apache

0 4 1 Jan */usr/local/etc/rc.d/lighttpd restart
4-point restart of Apache on January 1


My csdn Blog address: Http://blog.csdn.net/caicongyang












Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Linux under crontab simple use

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.