The at command
reads commands from standard input or from a shell script and executes them at a later time specified by the user. A command list created in this way runs under a job number. (Format 1 and 2)
lists on standard output any jobs scheduled with at or batch (see batch) which have not yet been processed (Format 3 and 4)
removes jobs previously scheduled with at or batch (Format 5).
The output from Format 1 and Format 2 is sent to the user by mailx unless the standard output and standard error output of the commands to be executed have been redirected.
The environment variables, the current directory, the permissions for new files (see umask "umask get or set the file mode creation mask") and the maximum permissible file size (see ulimit "ulimit set or report file size limit") are retained, but open files and priorities are lost, and the trap command (shell built-in for catching signals) is deactivated. at writes the job number and the schedule time to standard error.
Jobs scheduled with at are retained even if the user who scheduled them closes the POSIX shell with exit or if the POSIX subsystem is shut down. There is no need to reschedule the jobs.
Before the call
The user ID must have a standard account number for rlogin access. This standard account number can be assigned using the ADD-USER, MODIFY-USER-ATTRIBUTES or ADD-POSIX-USER command.
If the file /usr/lib/cron.d/at.allow exists, you can only use at if your login name appears in it.
If the file /usr/lib/cron.d/at.allow does not exist, you can only use at if your login name does not appear in the file /usr/lib/cron.d/at.deny.
If neither /usr/lib/cron.d/at.allow nor /usr/lib/cron.d/at.deny exists, only the POSIX administrator is allowed to use at.
If only an empty deny file exists, for example, everyone is allowed to use at.
Only the POSIX administrator is allowed to create and modify the allow and deny files. Each line in these files contains precisely one login name.
The cron daemon is started by means of an rc script.
Syntax
Format 1: | at[ -m][ -f script][ -q queue] -t time |
Format 2: | at[ -m][ -f script][ -q queue] time |
Format 3: | at -l[ jobnumber] |
Format 4: | at -l -q queue |
Format 5: | at -r jobnumber |
Execute commands at a later time
at reads the commands to be executed from the specified shell script. -f not specified:
Sends mail to the user after a job has been completed, indicating that the job is finished. Mail is sent only if the job has not already generated a mail message.
The -q option is used to assign a job to a specific queue in the /var/spool/cron directory. The values accepted for queue are:
Specifies the execution time for the commands. time is specified as follows: [[CC]YY]MMDDhhmm[.SS] CC The first two digits of a date (century). YY Two-digit year specification. MM Two-digit month specification (01 bis 12) DD Two-digit day specification (01 bis 31) hh Two-digit hour specification (00 bis 23) mm Two-digit minute specification (00 bis 59) SS Two-digit second specification (00 bis 61) |
The options are described under Format 1.
Specifies the execution time for the commands. time is specified as follows: time: digits[suffix] or special_name digits [h]h hhmm [h]h:[m]m 1- and 2-digit numbers are interpreted as hours. 4-digit numbers are interpreted as hours and minutes. Digits separated by a colon are interpreted as hours and minutes. suffix am Interpreted as before 12 noon (dependent from the locale LC_TIME) pm Interpreted as after 12 noon (dependent from the locale LC_TIME) am, pm omitted: Interpreted as 24-hour clock utc[am|pm] or zulu[am|pm] Interpreted as UTC (Coordinated Universal Time) special_name noon, midnight, now date: month month (dependent from the locale LC_TIME) jan[uary], feb[uary], mar[ch], apr[il], may, jun[e], jul[y], aug[ust], sep[tember], oct[ober], nov[ember], dec[ember], nextmonth | next day A number between 1 and 31, depending on how long the month is. year Number defining the year to which the date applies weekday (dependent from the locale LC_TIME): mon[day], tue[sday], wed[nesday], thu[rsday], fri[day], sat[urday], sun[day] nextweek | next selects the following week special_day today, tomorrow, nextday, next nextday (or next date not specified: corresponds to today if the specified time (rounded to the nearest minute) lies after the current time corresponds to tomorrow if the specified time (rounded to the nearest minute) lies after the current time corresponds to now if the specified time (rounded to the nearest minute) lies after the current time +increment increment is a positive integer that must be followed by one of the following units of time: |
Example: at can typically be specified in the following ways: at 0815am jan 24 at 8:15am jan 24 at 5pm friday at now +1hour |
List jobs yet processed
Format 3: | at -l[ jobnumber] |
Format 4: | at -l -q queue |
-l[ jobnumber]
at lists the specified jobnumber, if the corresponding job has not yet been processed. jobnumber is the number that is reported on standard error when a job is scheduled with at, batch or cron.
jobnumber not specified:
at lists all jobs that are yet to be processed, together with their job numbers.
-l -q queue
It is possible to specify the queue as an alternative to the jobnumber. at lists all of the jobs in queue.
Remove jobs
Format 5: | at -r jobnumber |
-r jobnumber
at removes the job jobnumber, which was previously scheduled with at or batch. jobnumber is the number reported on standard error when a command job is scheduled with at or batch. You can specify more than one job number, using blanks to separate them. Only the POSIX administrator is authorized to remove another user's jobs.
Error
The commonest error messages are:
You have entered the date in an incorrect format.
The date you specified has already passed.
time lies between "now" and "now+1hour".
You are not authorized to use at. Sorry. (See Before the call) |
File
/usr/lib/cron/at.allow List of login names with permission to use at. One login name is entered per line. /usr/lib/cron/at.deny List of login names explicitly denied permission to use at. One login name is entered per line /var/spool/cron/atjobs Directory containing a separate file for each at job which has not yet been executed. Each at job is allocated a file of its own with the file name jobnumber.a. |
Variable
SHELL Determine a name of a command interpreter to be used to invoke the at job. If the variable is unset or null, sh will be used. If it is set to a value other than a name for sh, the implementation will do one of the following: use that shell; use sh; use the login shell from the user database. TZ Determine the timezone. The job will be submitted for execution at the time specified be timespec or -t time relative to the timezone specified by the TZ variable. If timespec specifies a timezone, it will override TZ. If timespec does not specify a timezone and TZ is unset or null, an unspecified default timezone will be used. |
Locale
The following environment variables affect the execution of at: LANG Provide a default value for the internationalization variables that are unset or null. If LANG is unset of null, the corresponding value from the implementation-specific default locale will be used. If any of the internationalization variables contains an invalid setting, the utility will behave as if none of the variables had been defined. LC_ALL If set to a non-empty string value, override the values of all the other internationalization variables. LC_CTYPE Determine the locale for the interpretation of sequences of bytes of text data as characters (for example, single- as opposed to multi-byte characters in arguments and input files). LC_MESSAGES Determine the locale that should be used to affect the format and contents of diagnostic messages written to standard error and informative messages written to standard output. LC_TIME Determine the format of date and time string. NLSPATH Determine the location of message catalogs for the processing of LC_MESSAGES. |
Example
The current date and the string April Fool! are to be displayed on terminal tty013 at 9 o’clock in the morning on the 1st of April.
CTRL+D or @@d |
See also
batch, crontab, date, kill, mailx, nice, ps, sh, sort |