Linux crontab use

Source: Internet
Author: User

1. Viewing, editing, and deleting

Cron saves the command line in the crontab (cron table) file, which is usually in the/etc directory. Each system user can have their own crontab (under/var/spool/cron/). To view the current user's crontab, enter crontab-l; To edit crontab, enter crontab-e; To delete crontab, enter Crontab-r. If you are currently root, to view/edit/delete/a user's crontab, simply add the-u USERNAME (such as crontab-e-U USERNAME) after the corresponding command. The default editor for the crontab file is VI, and you can enter export visual= ' editor ' to change the default editor. Cron service every minute not only to read all the files in the/var/spool/cron directory, but also to read the/etc/crontab file once. Configuring this file also allows Cron to perform tasks. Using the crontab command is a configuration of a user-level task, and editing a/etc/crontab file is a configuration of a system-level task.

2.Linux Task Start

/sbin/service crond start/sbin/service crond stop/sbin/service crond restart/sbin/service crond reload/sbin/service Crond status

3.cron Time Format

crontab format 1th column minute 1~59 2nd Column hour 1~23 (0 means midnight) 3rd Liege 1~31 4th Column Month 1~12 5th Column Week 0~6 (0 = Sunday) 6th column to run the command below is the format of crontab: Time-sharing day and month Commands to run here are some examples of crontab file entries: * * * * * * * * * * * * * * * * * * * * * * * * * * */usr/local/apache/bin/apachectl Restart above shows the 21:30 restart Apache per night 4 1,10,22 * */usr/local/apache/bin/apachectl Restart the above example shows the 4:45 restart Apache per month for 1, 10, 22nd. 1 * * 6,0/usr/local/apache/bin/apachectl Restart the above example shows that 1:10 restarts Apache every Saturday and Sunday. 0,30 18-23 * * * */usr/local/apache/bin/apachectl Restart the above example shows that Apache restarts every 30 minutes from 18:00 to 23:00 every day. 0 * * 6/usr/local/apache/bin/apachectl Restart the above example indicates that the Apache is restarted every Saturday. * */1 * * * */usr/local/apache/bin/apachectl Restart restart every hour apache* 23-7/1 * */usr/local/apache/bin/apachectl restart 11 o'clock To 7 hours in the morning, restart every hour apache0 4 * mon-wed/usr/local/apache/bin/apachectl Restart monthly 4th and 11 points per Monday to Wednesday restart APACHE0 4 1 Jan */usr/loc Al/apache/bin/apachectl Restart January 1 4-point restart Apache

Linux crontab use

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.