· Do at once in the future (depending on the atd service)
· Perform cron periodically in the future (depending on the crond Service)
· Cron supplement (executed after startup) anacron (dependent on anacron service)
At:
The at command is used to schedule a one-time task within the specified time.
At [-mldv] TIME
Options and parameters:
-M: After the at task is completed, the user is notified by email even if no information is output.
-L: list all at tasks of the current user on the system (same as atq)
-D: cancels an at task (same as atrm)
-V: You can use an obvious time format to list at tasks.
-C: List the content of the subsequent task.
Time Format of the at command:
Now + time: the time is in the unit of minutes, hours, days, or weeks.
HH: MM: 24-hour system. If the time has passed, it will be executed at this time of the next day.
Midnight: 00: 00
Noon: 12: 00
Teatime: 16: 00
[Root @ rhel6 ~] # At // define an at task to be executed
At> date>/tmp/at // enter the current time in the/tmp/at file.
At> echo "at command test">/tmp/
At> uname-r>/tmp/
At> <EOT> // select another line and press Ctrl + D to exit the at command mode.
Job 1
[Root @ rhel6 ~] # At now + 1 minutes // define another at task to be executed in 1 minute
At> date>/tmp/
At> echo "at command test again">/tmp/
At> sleep 10
At> date>/tmp/
At> <EOT>
Job 2
[Root @ rhel6 ~] # Date
Fri December 28 13:09:09 CST 2012
[Root @ rhel6 ~] # Atq // display all at tasks in the system
2 2012-12-28 13:10 a root
1 2012-12-28 13:10 a root
[Root @ rhel6 ~] # Cat/tmp/
Fri December 28 13:10:00 CST 2012
Fri December 28 13:10:00 CST 2012
At command test
At command test again
2.6.32-220. el6.x86 _ 64
Fri Dec 28 13:10:10 CST 2012 // compare the two times. It can be seen that at tasks execute commands in order.
Supplement: batch
The batch command is used to execute a one-time task when the average system load is less than 0.8%. It is used in the same way as.
[Root @ rhel6 ~] # Batch midnight // run the command after when the average system load reaches below 0.8%
At> sync
At> sync
At> shutdown-h now
At> <EOT>
Job 3
[Root @ www ~] # Atq
3 2012-12-28 13:20 B root
[Root @ www ~] # Atrm 3 // cancel the batch task
The/etc/at. allow and/etc/at. deny files can be used to restrict the use of at and batch Commands (root users are not controlled ). The two control files are formatted as one user per line (spaces are not allowed). After the files are modified, the atd daemon does not need to be restarted.
If the at. allow file exists, only the listed users are allowed to use the at or batch command, and the cron. deny file is ignored. If the at. allow file does not exist, all users listed in cron. deny will not use at and batch.