At: For performing one-time tasks
at related configuration files/etc/at.allow/etc/at.deny
If a/etc/at.allow file exists, only the users included in the At.allow are allowed to use at;
If the/etc/at.allow file does not exist, the/etc/allow.deny file is checked, and users not included in the At.deny file are allowed to use the at;
If none of the two files exist, only root is allowed to use at;
By default, there is an empty/etc/at.deny that allows all users to use at.
ATQ= at–l Query Task queue
[Email protected] ~]# ATQ
9 2014-08-29 17:00 a root
8 2014-08-28 16:00 a root
[Email protected] ~]# at-l
9 2014-08-29 17:00 a root
8 2014-08-28 16:00 a root
ATRM= at–d Delete Task
[Email protected] ~]# ATRM 8
[Email protected] ~]# ATQ
9 2014-08-29 17:00 a root
At 18:00 tomorrow–f fileRead a task from a file
[Email protected] ~]# at 18:00 tomorrow-f ccdb_rsync.sh
Job at 2014-08-29 18:00
[Email protected] ~]# ATQ
9 2014-08-29 17:00 a root
Ten 2014-08-29 18:00 a root
2014-08-29 18:00 a root
At 4pm + 3 daysPerform a task at 4 o'clock in the afternoon in 3 days
[[email protected] ~]# at 4pm + 3 days
at> echo "Hello"
At> <EOT>
Job at 2014-08-31 16:00
At 10:10 Sep 1At 10:10 on September 1, the mission was executed.
[Email protected] ~]# at 10:10 Sep 1
at> echo "Hello"
At> <EOT>
Job at 2014-09-01 10:10
crontab:Used to perform recurring tasks
crontab related configuration files:/var/spool/cron/etc/cron.allow/etc/cron.deny
/var/spool/cron/: The directory used to save the user's tasks
If a/etc/cron.allow file exists, only users who exist in the Cron.allow file are allowed to use crontab;
If a/etc/cron.deny file is present, only users stored in the Cron.deny file are denied use of crontab;
If/etc/cron.allow/etc/cron.deny is not present, only root is allowed to use crontab.
crontab–l display Task List
Crontab–e Editing Tasks
[Email protected] cron]# crontab-l
*/5 * * * * echo "Hello world!"
0 5 * * * Touch file_ ' date +\%f '. txt
Crontab the format of a task
[Email protected] ~]# Cat/etc/crontab
Shell=/bin/bash
Path=/sbin:/bin:/usr/sbin:/usr/bin
Mailto=root
home=/
# for details see Mans 4 Crontabs
# Example of Job definition:
#.----------------Minute (0-59)
# | .-------------Hour (0-23)
# | | .----------Day of Month (1-31)
# | | | .-------month (1-12) OR jan,feb,mar,apr ...
# | | | | .----Day of Week (0-6) (sunday=0 or 7) or Sun,mon,tue,wed,thu,fri,sat
# | | | | |
# * * * * * * user-name command to be executed
1th *: Sub (0-59)
2nd *: Hours (0-23)
3rd *: Day (1-31)
4th *: Month (1-12)
5th *: Week (0-6 or Sun,mon,tue,wed,thu,fri,sat)
command to be executed: represents executed commands
Cases:
1. Execute once every 5 minutes
*/5 * * * * echo "Hello World"
2.10 minutes per hour, 20-30 minutes to execute
10,20-30 * * * * echo "Hello World"
3. Perform a second-level task that executes every 10 seconds
* * * * * for i in {1..5}; Do/bin/echo "How is it?"; Sleep Done
4. If you execute a command that contains%, you need to escape
0 5 * * * Touch file_ ' date +\%f '. txt
Or
0 5 * * * Touch file_ ' date + '%F '. txt
Anacron
Anacron is also used to perform periodic tasks, with frequencies of hourly, daily, weekly, monthly correspondence to/etc/cron.hourly,/etc/cron.daily,/etc/cron.weekly,/etc/monthly;
The Anacron is primarily used for systems that are not 24-hour power-up and perform tasks by reading/etc/anacrontab files.
Linux Scheduled tasks at Crontab Anacron