AT Linux Command
What is Linux at Command?
Explanation
at COMMAND:The at command schedules a command to be run once at a later time or a scheduled time. The "at" command is run at the command line, passing it the scheduled time as the option. The exact command to be run at the scheduled time can be typed in a special prompt. When you're done, press Control-D to exit the special prompt and the command will be placed in the queue. You can set the time in many different ways and even have the result mailed to you after the command has been executed. The command will be executed using the order a) $SHELL b) login shell c) /bin/sh.
For example to run a backup-script at say 12:30 AM, the job can be scheduled as below:
#] at 12:32 -m -f /usr/local/bin/backup-script
SYNTAX :
at [-V] [-q x] [-f file] [-mMlbv] timespec ...
at [-V] [-q x] [-f file] [-mMlbv] -t time
at -c job ...
atq [-V] [-q x]
at [ -rd ] job ...
atrm [-V] job ...
batch
OPTIONS:
-V |
prints the version number to standard error. |
-q queue |
uses the specified queue. A queue designation consists of a single letter; valid queue designations range from a to z. and A to Z. The a queue is the default for at and the b queue for batch. Queues with higher letters run with increased niceness. The special queue "=" is reserved for jobs which are currently running. |
-m |
Send mail to the user when the job has completed even if there was no output. |
-f file |
Reads the job from file rather than standard input. |
-l |
Is an alias for atq. |
-d |
Is an alias for atrm. |
-v |
Shows the time the job will be executed. |
EXAMPLE:
- Here, the typical at command example :
at 10:30 PM Thu
The above will display output like this:
warning: commands will be executed using /bin/sh
at> echo "Welcome, it's 10.30 AM on Thursday."
at>
job 1 at Thu Jan 14 10:30:00 2016
While running the "at" command a "warning" message is first displayed saying in which command shell, the commands are run: in this case, /bin/sh, the Bourne Shell. This is the traditional standard Unix shell.
It then places us at the at> prompt, which is a special prompt where we type in a simple echo command, which simply echoes a string of text. We press enter, and we're placed at a new at> prompt. We then press Control-D informing the "at" command that we're all done with our commands. Then the commands are saved in the queue and we are informed of the JOB NUMBER for the command we have entered (job number 1) and that it will run next Tuesday.
- If you don't specify a time at the command line :
at
at will return the following error message:
Garbled time