I recently wanted to run a set of commands on a Linux machine at some point in the future. I knew about using cron to schedule a set of commands at defined intervals, but I only wanted to run the commands once at a specific time on a specific date. After searching the internet I found the at command, which allowed me to do exactly what I wanted.

The at command will execute a command or a script at a later time or date and allows for some fairly complex time specifications. Below are two examples of the at command:

1) using at to execute commands taken from stdin at 17:00 on the same day:

$ at 17:00
at> ...
at> ...
at> <eot>
job 1 at 2009-06-22 17:00

2) using at to execute commands from a file on a June 19 at 17:00:

$ at -f myscript.sh 17:00 Jun 26
job 2 at 2009-06-26 17:00

You can also use atq to list the scheduled jobs, as follows:

$ atq
1      Mon Jun 22 17:00:00 2009 a ajones
2      Fri Jun 26 17:00:00 2009 a ajones

The atrm command allows you to remove a scheduled job:

$ atrm 1
$ atq
2      Fri Jun 26 17:00:00 2009 a ajones