The at Command Syntax


©2002 by Wayne Pollock, Tampa Florida USA.  All rights reserved.


Entering Dates and Times:

The table below show some (not all!) of the ways you can enter dates and times for the at command.  Although different Unix systems may have slightly different syntaxes (check the local man pages) in general the syntax is:

    at TIME [ DATE ]

In all cases of specifying a time only, the command will run at that time today if the specified time is in the future, or tomorrow otherwise.  For example if you specify 3:00 PM and it is currently only 1:00 PM, the at job will run in two hours from now.  But if is is currently 3:30 PM, the job will run tomorrow at 3 PM.

(See your local man pages for details on other options to at.)

In the examples below assume that the date and time currently is:
10:00 AM Tuesday, September 18, 2001
Example Meaning
at noon 12:00 PM September 18, 2001
at midnight 12:00 AM September 19, 2001
at teatime 4:00 PM September 18, 2001
at tomorrow 10:00 AM September 19, 2001
at noon tomorrow 12:00 PM September 19, 2001
at next week 10:00 AM September 25, 2001
at next monday 10:00 AM September 24, 2001
at fri 10:00 AM September 21, 2001
at OCT 10:00 AM October 18, 2001
at 9:00 AM 9:00 AM September 19, 2001
at 2:30 PM 2:30 PM September 18, 2001
at 1430 2:30 PM September 18, 2001
at 2:30 PM tomorrow 2:30 PM September 19, 2001
at 2:30 PM next month 2:30 PM October 18, 2001
at 2:30 PM Fri 2:30 PM September 21, 2001
at 2:30 PM 9/21 2:30 PM September 21, 2001
at 2:30 PM Sept 21 2:30 PM September 21, 2001
at 2:30 PM 9/21/2010 2:30 PM September 21, 2010
at 2:30 PM 21.9.10 2:30 PM September 21, 2010
at now + 30 minutes 10:30 AM September 18, 2001
at now + 1 hour 11:00 AM September 18, 2001
at now + 2 days 10:00 AM September 20, 2001
at 4 PM + 2 days 4:00 PM September 20, 2001
at now + 3 weeks 10:00 AM October 9, 2001
at now + 4 months 10:00 AM January 18, 2002
at now + 5 years 10:00 AM September 18, 2007


Access Control:

This is controlled by a pair of files called at.allow and at.deny.  The location and even the exact use of these files vary from system to system.  For Linux these file exists in /etc.  On Linux:


Other Commands and Options:

To see a list of pending at jobs (the ones that haven't run yet), use the command "atq".  This will show the job number and date-time for that job.

To see the contents of some at job, use the command "at -c jobnum".  This shows the complete environment that gets set for the job as well; the actual commands of your job are at the bottom.

To delete an at job before it has run, use the command atrm jobnum".

An at job may be created in a particular queue, using the form "at -q queue date-time".  The queue is a single letter.  The default queue is "a".  Queue "b" is reserved for batch jobs.  Using higher lettered queues will run your at job with higher nice values.


Example: Using at for a Reminder Message

Suppose today is Tuesday, September 18, 2001 at 4 PM.  Then the following will "pop-up" a reminder message on Friday, September 21, 2001 at 3:00 PM for someone whose account name is user:

/home/user> at 3 PM Fri
at> echo "Leave now for 4 PM PTA meeting" | write user >/dev/null 2>&1
at> ^D
warning: commands will be executed using /bin/sh
job 1 at 2001-09-21 15:00
/home/user> _

Longer messages can be saved in a file.  In that case use cat file instead of echo message

The reason to use write is that at jobs are not attached to your current (or any future) terminal session.  Without the write command, the output of the echo command is sent as email to the user.  Note that in the example above any output or errors from the write command are discarded to avoid sending email to the user in the event user is not logged in at 3:00 PM on Friday.  If you would like such email then eliminate the I/O redirections to /dev/null.  (In fact this is quite common.)