Linux at command and linuxat command
The at command is used to execute commands at a specified time.
At allows a quite complex set of time-based methods. It can be specified in the hh: mm (hour: minute) format of the current day.
If the time has passed, it will be executed on the next day. Of course, you can also use vague words such as midnight (late night), noon (noon), teatime (tea time, usually four o'clock P.M.) to specify the time.
The user can also use a 12-hour hourly system, that is, add AM (morning) or PM (afternoon) after the time to indicate whether it is morning or afternoon. You can also specify the specific date of command execution, in the format of month day (month day), mm/dd/yy (month/day/year) or dd. mm. yy (Day. month. year ). The specified date must be later than the specified time.
The above is the absolute timing method. In fact, the relative timing method can be used, which is very good for the command to be executed soon.
The specified format is: now + count time-units, now is the current time, and time-units is the time unit. Here it can be minutes (minutes), hours (hours), days (days) and weeks (week ). Count indicates the number of times, days, hours, and so on. Another method of timing is to use today (today) and tomorrow (tomorrow) to specify the time for command completion.
Syntax
Option
-F: Specifies the task file containing specific commands;
-Q: Specify the queue name of the new task;
-L: displays the list of tasks to be executed;
-D: Delete the specified task to be executed;
-M: After the task is executed, the system sends an email to the user.
Parameters
Datetime: Specifies the date and time when the task is executed.
Instance
Execute/bin/ls at five o'clock P.M. three days later:
[root@localhost ~]# at 5pm+3 days
at> /bin/ls at> job 7 at 2016-01-08 17:00
The output time will be within the specified file at tomorrow:
[root@localhost ~]# at 17:20 tomorrow
at> date >/root/2016.log
at> job 8
at 2016-01-09 17:20
After the scheduled task is set, we can run the atq command to check whether the system has executed the task:
[root@localhost ~]# atq
8 2016-01-06 17:20 a root
7 2016-01-08 17:00 a root
Delete A set task:
[root@localhost ~]# atq
8 2016-01-06 17:20 a root
7 2016-01-08 17:00 a root
[root@localhost ~]# atrm 7
[root@localhost ~]# atq
8 2016-01-06 17:20 a root
Display the configured task content:
[Root @ localhost ~] # At-c 8
#! /Bin/sh
# Atrun uid = 0 gid = 0
# Mail root 0 umask 22 n characters are omitted here
Date>/root/2016.log
Recommended website reference: http://man.linuxde.net/