Delay scheduled tasks and tasks under Linux

A delay task

System delay task is a system task or tasks set only made after a certain time at a specified time, this command initiates tasks are disposable. General command is initiated delayed tasksat

1, the basic usage
the specific time at + Perform tasks in a specific time delay
at now + time Delay the implementation of tasks from now after how long
at -l View delay task
at -c job号 View job details
at -r job号 Cancel mission

Here Insert Picture Description

2, black and white list system delayed tasks

The user is present in the system can perform the task delayed
Here Insert Picture Description
the establishment of the user delay the task blacklist, blacklist is /etc/at.deny, write user wang in the list of
Here Insert Picture Description
results show that a user wang can not perform the task delayed
Here Insert Picture Descriptionthe establishment of the task delayed the user's whitelist , whitelist /etc/at.allow, by default, this list does not exist, once this list exists, only the root user and the user can perform on the white list of delayed tasks. When the presence of the white list, black list are disabled by default.
Written in the whitelist wang user, the user again switched showed wang user can perform tasks delay, the user can not dan

3, system delays the output of tasks

When the delay has the task to the task output is sent to the message originator's mailbox form
Here Insert Picture DescriptionHere Insert Picture DescriptionHere Insert Picture Description

Second, regular tasks

Delay task at a one-time, only once, a permanent task is stored on disk, will never die.

Set the command mode Mode 1 ----

Tools developed for regular tasks: crontab
name of the service is: crontab.service

crontab -e edit
crontab -u Specifies the user

When developed using crontab scheduled tasks, time format is shown below

field allow values
minute 0-59
hour 0-23
day of month 1-31
month 1-12(or names)
day of week 0-7(0 or 7 is Sunday, or use name)

As shown below, the first row indicates: Empty per minute / mnt
second line indicates: every / mnt 5 minutes emptied
third row indicates: every / mnt emptied under five minutes between 8:00 to 11:00
of line represents: 1 month and between 8 and 11 every 15 dot / mnt under five minutes emptied
fifth row indicates: 1 and 8 to No. 15 of June 11 to October every inter / mnt emptied under five minutes
sixth line represents: between every June to October 1, and 8:00 to 11:00 every Saturday and 15 6 to 10 months under five minutes empty / mnt
Here Insert Picture Description

crontab -l -u root View all crontab under the root user
crontab -r -u root All will delete all under the root user crontab

Here Insert Picture Description

Setting 2 ---- Profiles way

Go to the directory where the configuration file cd /etc/cron.d, write the file format exist view directory and write in this directory regular tasks we need to
Here Insert Picture Descriptionview the files in a directory format sysstat
Here Insert Picture Descriptiontiming of writing tasks in the file wang
Here Insert Picture Description

crontab set blacklist

Set blacklist user wang in the file /etc/cron.deny
Here Insert Picture Description

crontab whitelist setting

Delay and whitelist similar tasks, timer task /etc/cron.allow whitelist, the user writes in wang list. By default, this list does not exist, once this list exists, only the root user and the user can perform on the white list of delayed tasks. When the presence of the white list, black list are disabled by default.
Here Insert Picture Description

Published 28 original articles · won praise 0 · Views 769

Guess you like

Origin blog.csdn.net/weixin_43834060/article/details/104457310