Crontab use instance of scheduled task in Linux

Source: Internet
Author: User


1, the outline of the planning task;

The task of planning is to perform the work that has been planned at the agreed time, which is the superficial meaning. In Linux, we often use the Crond server to do this work. A cron server can perform a specific service based on the time of the profile appointment. For example, we can in the configuration file agreed every morning 4, the httpd server reboot, this is a scheduled task;

Now let's talk about cron;


2, Cron;

In a Linux system, the scheduling task is typically done by cron, and we can set the cron to start automatically when it is powered on. When Cron starts, it reads all of its configuration files (the global profile/etc/crontab, and the scheduled task profile for each user), and then Cron invokes the task on time according to the command and execution time.


Installation and start-up of 2.1 cron;

In general, Cron is installed by default, we have to learn to see if the package has been installed;

Crontab Use examples:

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

The above example represents 21:30 restart Apache per night.

4 1,10,22 * */USR/LOCAL/ETC/RC.D/LIGHTTPD restart

The above example represents the 4:45 reboot of Apache for 1, 10, and 22nd per month.

1 * * 6,0/USR/LOCAL/ETC/RC.D/LIGHTTPD restart

The above example shows the 1:10 reboot of Apache every Saturday and Sunday.

0,30 18-23 * * * */usr/local/etc/rc.d/lighttpd restart

The example above shows that Apache is restarted every 30 minutes from 18:00 to 23:00 every day.

0 * * 6/USR/LOCAL/ETC/RC.D/LIGHTTPD restart

The above example indicates that 11:00 PM restarts Apache every Saturday.

* */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 points per Monday to Wednesday restart Apache

0 4 1/USR/LOCAL/ETC/RC.D/LIGHTTPD * Restart

Restart Apache at 4 o ' January 1.

*/30 * * * */usr/sbin/ntpdate 210.72.145.44

Sync time every half hour

Other: Timed access to a specified URL

30 access to this URL every day 3 o'clock in the morning

3 * * */usr/bin/wget-q-o temp.txt http://mb.111cn.net

Access this URL every 10 minutes

*/10 * * * */usr/bin/wget-q-o temp.txt http://www.111cn.net

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.