Scheduled Tasks, recurring task settings in Linux

Source: Internet
Author: User

Scheduled Tasks, recurring task settings in Linux

Scheduled Task : The execution of a specific task at a specific time in the future. Of course, if the same task needs to execute twice, three or more times at different points in time, it can be treated as multiple times.

Recurring Task : Refers to a task that requires periodic execution. Periodicity can be in points, hours, Tian Deng units, but not limited to these units.

Commands that are commonly used to perform scheduled Tasks--at, batch, and the command crontabs associated with a recurring task.

The difference between the 1.at command and the batch command.

The AT command is intended to perform a task between specific tasks; The tasks set by the batch command are selected by the system for idle time, while idle time defaults to a CPU utilization rate of less than 0.8

2.at command
format at [option] Time option -L ATQ command alias, display user's scheduled task -D atrm command alias, empty scheduled task -C View specific plan Task -F file   reads a scheduled task command from a file

Time, there are several formats
   hh:mm [YYYY-MM-DD]
Noon, midnight, teatime
Tomorrow
Now+#{minutes,hours,days, Weeks}

Note: The batch command uses a method similar to at, and is not mentioned here
 
3. Crontabs command

A. There are three packages related to the Cron service:

Cronie: Main package, providing Crond daemon and related auxiliary tools

Cronie-anacron:cronie supplementary procedure for monitoring Cronie task execution

Crontabs: Includes centos to provide system maintenance tasks

B. periodic task classification . According to the user level, can be divided into system cycle tasks and user cycle tasks.

C. System cycle tasks you can configure periodic tasks by directly modifying the /etc/crontab file directly to view the contents of the file

[[email protected] tmp] #cat/etc/crontab SHELL=/bin/Bash PATH=/sbin:/bin:/usr/sbin:/usr/Bin # environment variable path mailto=Root # After the cycle task is executed, the Mail recipient home=/# for details see Mans4crontabs# Example of Job Definition: # Scheduled Task write format #.----------------Minute (0- -) #| .-------------Hour (0- at)# |  | .----------Day of Month (1- to)# |  |  | .-------Month (1- A) OR jan,feb,mar,apr ... #|  |  |  | .----Day of Week (0-6) (sunday=0Or7) OR sun,mon,tue,wed,thu,fri,sat#|  |  |  | |# * * * * * * user-name command to be executed

D. In the cycle task, the/etc/crontab file shows that there are 5 time-dependent options, which have the following rules:

A. Specific value #
Example: 5 or 20

B. can use * to indicate any value
C. Discrete values separated by commas
For example: 5,6,2 or 0,3
D. Continuous value with a short polyline "-" means

Example: 10-21

E. Forward slash "/" ' step size can be used:
Example: */3

E. When you configure user-cycle tasks, you can directly use the

    Crontabs-e

Edit the relevant configuration file, file format and/etc/crontab similar, just do not need to fill out the user-name option. Other options:

Crontab   -e     Direct Edit file           -L  View cycle task            -R empty Cycle task  -i  interactive mode
     -U USER: Only root can run, specify to perform the cycle task as a specific user

F. User cycle tasks, with their own unique time format, @CMD-can represent a specific cycle time

0 1 1 *011 *01 * *0 0 0 * * * * * * *   
4. Related Configuration Files

/etc/crontab
/etc/cron.d/configuration file
/etc/cron.hourly/Script
/etc/cron.daily/Script
/etc/cron.weekly/Script
/etc/cron.monthly/Script

/etc/anacrontab is responsible for performing the system tasks in the above/etc/cron.hourly/and other documents.

/var/spool/cron/User Cycle Task profile

/etc/cron. {Allow,deny} permissions profile for user to perform periodic tasks

    

  

    

Scheduled Tasks, recurring task settings in Linux

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.