9.7.2. Using the at Command
The
at executes a command at a specified moment in the future. It takes the desired time and date as command-line parameters, and the command to be executed in its standard input. The command will be executed as if it had been entered in the current shell.
at even takes care to retain the current environment, in order to reproduce the same conditions when it executes the command. The time is indicated by following the usual conventions:
16:12 or
4:12pm represents 4:12 pm. The date can be specified in several European and Western formats, including
DD.MM.YY (
27.07.12 thus representing 27 July 2012),
YYYY-MM-DD (this same date being expressed as
2012-07-27),
MM/DD/[CC]YY (ie.,
12/25/12 or
12/25/2012 will be December 25, 2012), or simple
MMDD[CC]YY (so that
122512 or
12252012 will, likewise, represent December 25, 2012). Without it, the command will be executed as soon as the clock reaches the time indicated (the same day, or tomorrow if that time has already passed on the same day). You can also simply write “today” or “tomorrow”, which is self-explanatory.
An alternative syntax postpones the execution for a given duration:
at now + number period. The
period can be
minutes,
hours,
days, or
weeks. The
number simply indicates the number of said units that must elapse before execution of the command.
To cancel a task scheduled by
cron, simply run
crontab -e and delete the corresponding line in the
crontab file. For
at tasks, it is almost as easy: run
atrm task-number. The task number is indicated by the
at command when you scheduled it, but you can find it again with the
atq command, which gives the current list of scheduled tasks.