Linux Recurring Task plan detailed

Source: Internet
Author: User

Linux Recurring Task plan detailed


One-time task execution:

At,batch


At

Interactive: Let the user enter more than one command to execute at the at> prompt;

Batch processing: Writes the command of the task to the file by the at to call;


Use format :

At time

At >


CTRL+D: Submitting a task


At jobs have queues : represented by a single letter

View Job : At-l =atq
[[email protected] ~]# at 10:46at> ls-ld/etcat> <eot>job 1 at 2015-08-25 10:46[[email protected] ~]# at-l12 015-08-25 10:46 a root

Delete a job that has not been executed :

At-d Job_num

ATRM Job_num

[[email protected] ~]# at-l22015-08-25 10:55 a root[[email protected] ~]# at-d 2

At batch mode :

At-f/path/to/at_job_file Time
[[email protected] ~]# at-f at.txt 10:55job 2 at 2015-08-25 10:55

Time: Blur Times

Now,noon,midnight,teatime,tomoroow
[Email protected] ~]# at now+5minat> ls-l/tmpat> cat/etc/issueat> <eot>job 4 at 2015-08-25 11:00
Note: The execution results of a task plan are sent to the task submitter by mail!!!


Recurring Task Scheduler: Cron


Crond: Daemon

Service process: Blocking, polling

System cron:

Files:/etc/crontab

In a system cron, any command that is to be executed periodically will not be kept consistent with the variables of any user's path, but

defined by its own environment variable;

User cron:

/var/spoo;/cron/username


Etc/crontab files: Define a separate task for each row

[[Email protected] ~]# cat /etc/crontab shell=/bin/bashpath=/sbin:/bin:/usr/sbin:/usr /binmailto=roothome=/# for details see man 4 crontabs# example of  job definition:  define job # .---------------- minute  (0 - 59)   minutes # &NBSP;|&NBSP;&NBSP:------------- hour  (0 - 23)   hours # |  |  .- --------- day of month  (1 - 31)   days # |  |  |  &NBSP:------- month  (1 - 12)  OR jan,feb,mar,apr ...  month # |  &NBSP;|&NBSP;&NBSP;|&NBSP;&NBSP;|&NBSP;&NBSP---- day of week  (0 - 6) (sunday=0 &NBSP;OR&NBSP;7) or sun,mon,tue,wed,thu,fri,sat  Week # |  |  |  |   |# *  *  *  *  * user-name command to  be executed

Time notation:

1. Each time bit should use the value within the range of valid values for which it is available

2. * On a time bit indicates all valid values for the corresponding bit

3,-: consecutive time adjacent points to take the value of 1-5

4., discrete time point value 1, 5

5,/#: For the specified time range of every # once 5-45/3 * * * *


0/2 * * */bin/echo "Hello" &>/dev/null executed every 2 hours

Note: Reject messages with output redirection:

&>/dev/null

>/dev/null 2>&1


User cron: Use the crontab command to implement

-l: View your cron task List

-E: Open your own cron profile with the editor defined in the editor variable

-r: Remove crontab file


-u UserName: Configure crontab jobs for other users

reminder: If you use% in crontab user commands, you have to escape to \%

    5 3 * * */bin/touch ~/testfile_ ' date +\%y-\%m-\%d '. txt


After using single quotes,% can also not escape

    5 3 * * */bin/touch ~/testfile_ ' date + ' \%y-\%m-\%d ' . txt

[[email protected] ~]$ Crontab-lno crontab for Docker[email protected] ~]$ Crontab-eno crontab for docker-using an EMP Ty ONE*/3 * * * */bin/echo "How is it?" [Email protected] ~]# Ls/var/spool/cron/docker

Crontab file Format:

Blank rows are ignored

#开头行是注释

How to implement a second-level task:

* * * * * for i in {}n/echo

How to implement a second-level task:

* * * * for i in {0..4};d O/bin/echo "How is it?"; Sleep10;done

Anacron: is a supplement to crontab that checks whether a task in crontab has not been executed in the past period,

If it is not executed, it is executed at some point after the boot, regardless of whether the cycle arrives.



This article is from the "Ling" blog, make sure to keep this source http://19871018.blog.51cto.com/3485797/1689885

Linux Recurring Task plan detailed

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.