Task Scheduler for Linux Systems

Source: Internet
Author: User

Planning tasks for Linux systems

Linux system Operations Engineers most of the management work is done by automatically executing a script on a regular basis.

Cron function is very important, remember!!!

Planning function Crontab:

    • -U: (user) indicates that a user is specified and no-U is the current user

    • -E: Indicates that a scheduled task is specified

    • -L: (list) indicates a scheduled task is listed

    • -R: (remove) to delete scheduled tasks

#crontab-e01 3 echo "OK" >/root/cron.log

Command explanation: Write a task plan that actually uses VIM to open the crontab configuration file

01 10 05 06 3 in turn, "time-sharing Week" command line

As indicated on June 5 (must be Wednesday) 10:01 perform echo "OK" >/root/cron.log

Crontab-e actually open a/var/spool/cron/username file

If the user is root, open the /var/spool/cron/root

★ Note: Do not use vim directly to edit, will be wrong, must use CRONTAB-E to edit


View the Scheduled Tasks

#crontab-L

Delete a scheduled task

#crontab-R

Crontab Exercises

    1. 14th per month, 4:10 "/bin/sh/usr/local/sbin/ backup_month.sh "

    2. execute every 8 hours ntpdate time.windows.com "

    3. "/bin/sh/usr/local/sbin/test2.sh"

    at 9 to 18 O ' Day

exercise answer:

1.   20 1 * * *  echo  ""  >/var/log/slow.log 

2.   0 3 * * 0  /bin/sh /usr/local/sbin/backup.sh

3.  10  4 14 * *  /bin/sh /usr/local/sbin/backup_month.sh

4.  0  */8 * * *  ntpdate time.windows.com

5.  0 1,12,18  * * *  /bin/sh /usr/local/sbin/test.sh

6.  0 9-18 *  * *  /bin/sh /usr/local/sbin/test2.sh


Every 8 hours, is to use all the hours (0-23) to remove 8, think about the results, in fact, it should be 0,8,16 three number.

When encountering multiple numbers (minutes, hours, months, weeks) such as the 5th question, you need to separate them with commas.

and the time period can be used n-m , as in the sixth question (9-18).

After all the scheduled tasks are set up, you need to check to see if the Crond service is started:

#service crond Status


If it is a stop state, you need to start it:

#service Crond Start



This article is from the "Old seven Linux Operations Management" blog, please be sure to keep this source http://asd9577.blog.51cto.com/4291946/1930304

Task Scheduler for Linux Systems

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.