[ Bottom of Page | Previous Page | Next Page | Contents | Index | Library Home | Legal | Search ]

Commands Reference, Volume 1

at Command

Purpose

Runs commands at a later time.

Syntax

To Schedule Jobs to Run at a Later Time

at [ -c | -k | -s | -q Queue ] [ -m ] [ -f File ] { -t Date |Time [ Day ] [ Increment ] }

To Report Scheduled Jobs

at -l [ -o ] [ Job ... | -q Queue ]

at -n [ User ]

To Remove Scheduled Jobs

at -r [ -F ] [ -i ] Job ...

at -r [ -F ] [ -i ] -u User

Description

The at command reads from standard input the names of commands to be run at a later time and allows you to specify when the commands should be run.

The at command mails you all output from standard output and standard error for the scheduled commands, unless you redirect that output. It also writes the job number and the scheduled time to standard error.

When the at command is executed, it retains the current process environment. It does not retain open file descriptors, traps, and priority.

The /var/adm/cron/at.allow and /var/adm/cron/at.deny files control that users can use the at command. A person with root user authority can create, edit, or delete these files. Entries in these files are user login names with one name to a line. The following is an example of an at.allow file:

root
nick
dee
sarah

If the at.allow file exists, only users whose login names appear in it can use the at command. A system administrator can explicitly stop a user from using the at command by listing the user's login name in the at.deny file. If only the at.deny file exists, any user whose name does not appear in the file can use the at command.

A user cannot use the at command if one of the following is true:

If the at.allow file does not exist and the at.deny file does not exist or is empty, only someone with root user authority can submit a job with the at command.

To schedule a job to run at a later time, you must specify a time to start the job. You may specify the time by using either the -t Date flag or the Time, Day, and Increment parameters.

The Date variable to the -t flag is specified using the following format:

[[CC]YY]MMDDhhmm[.SS]

The digits in the Date variable are defined as follows:

CC Specifies the first two digits of the year (the century).
YY Specifies the second two digits of the year.
MM Specifies the month of the year (01 through 12).
DD Specifies the day of the month (01 through 31).
hh Specifies the hour of the day (00 through 23).
mm Specifies the minute of the hour (00 through 59).
SS Specifies the second of the minute (00 through 59).

Both the CC and YY digits are optional. If neither is given, the current year is assumed. If the YY digits are specified but the CC digits are not, the CC digits are defined as follows:

The resulting time is affected by the value of the TZ environment variable.

The Time parameter may be specified as a number followed by an optional suffix. The at command interprets one- and two-digit numbers as hours. It interprets four digits as hours and minutes. The T_FMT item in the LC_TIME locale category specifies the order of hours and minutes. The default order is the hour followed by the minute. You can also separate hours and minutes with a : (colon). The default order is Hour:Minute.

In addition, you may specify one of the following suffixes:

If you do not specify am or pm, the at command uses a 24-hour clock. These suffixes can follow the time as a separate argument or separated with spaces. The am and pm suffixes are defined values from the AM_STR and PM_STR items in the LC_TIME locale category. The suffix zulu indicates that the time is GMT (Greenwich Mean Time).

The at command also recognizes the following keywords as special values for the Time parameter:

You may specify the optional Day parameter as either a month name and a day number (and possibly a year number preceded by a comma), or a day of the week. The D_FMT item in the LC_TIME locale category specifies the order of the month and day (by default, month followed by day). The DAY_1 through DAY_7 items in the LC_TIME locale category specify long day names. The ABDAY_1 through ABDAY_7 items in the LC_TIME locale category specify short day names. The MON_1 through MON_12 items in the LC_TIME locale category specify long month names. The ABMON_1 through ABMON_12 items in the LC_TIME locale category specify short month names. By default, the long name is fully spelled out; the short name is abbreviated to two or more characters for weekdays, and three characters for months.

The at command recognizes today and tomorrow as special default values for the Day parameter. The today value is the default Day if the specified time is later than the current hour; the tomorrow value is the default if the time is earlier than the current hour. If the specified month is less than the current month (and a year is not given), next year is the default year.

Flags

-c Requests that the csh command be used for executing this job.
-f File Uses the specified file as input rather than using standard input.
-F Suppresses delete verification. Use this flag with the -r flag.
-i Specifies interactive delete. Use this flag with the -r flag.
-k Requests that the ksh command be used for executing this job.
-l Reports your scheduled jobs. If you have root user authority, you can get jobs issued by other users.
-m Mails a message to the user about the successful execution of the command.
-n [ User ] Reports the number of files in your queue. If you have root user authority, you can get information about another user's queue.
-o Lists jobs in schedule order. This flag is useful only with the -l flag.
-q Queue Specifies the queue in which to schedule a job for submission. When used with the -l flag, the report is limited to the queue specified by the Queue variable. By default, at jobs are scheduled in the a queue. The b, c and d queues are reserved for batch jobs, cron jobs, and sync jobs respectively.
-q a
Queues at jobs.
-q b
Queues batch jobs. The batch command calls the at command with this flag.

Note: When using the b queue, commands are read from standard input. Also, the now keyword is used for the Time parameter, regardless of what you specify on the command line.
 
 
-q e
Queues ksh jobs. Equivalent to the -k flag.
-q f
Queues csh jobs. Equivalent to the -c flag.
-r Job... Removes Jobs previously scheduled by the at or batch commands, where Job is the number assigned by the at or batch commands. If you do not have root user authority (see the su command), you can remove only your own jobs. The atrm command is available to the root user to remove jobs issued by other users or all jobs issued by a specific user.
-s Requests that the bsh command (Bourne shell) be used for executing this job.
-t Date Submits the job to be run at the time specified by the Date variable.
-u User Deletes all jobs for the specified user. If used with the -r flag, do not specify a Job variable (the correct syntax is at -r -u User).

Parameters

Day Specifies the optional Day parameter as either a month name and a day number (and possibly a year number preceded by a comma), or a day of the week.
Increment The optional Increment parameter can be one of the following:

Security

Auditing Events: If the auditing subsystem has been properly configured and is enabled, the at command will generate the following audit record (event) every time the command is executed:

Event Information
AT_JobAdd Lists at jobs that were run, the time the task was completed, and the user who issued the command.

See "Setting Up Auditing" in AIX 5L Version 5.2 Security Guide for more details about how to properly select and group audit events, and how to configure audit event data collection.

Exit Status

This command returns the following exit values:

0 The at command successfully submitted, removed, or listed a job or jobs.
>0 An error occurred.

Examples

  1. To schedule the command from the terminal, enter a command similar to one of the following:

    If uuclean is in your current directory, enter:

    at   5   pm   Friday
    uuclean
    <Ctrl-D>
     
    at   now   next   week
    uuclean
    <Ctrl-D>

    If uuclean is in $HOME/bin/uuclean, enter:

    at   now   +   2   days
    $HOME/bin/uuclean
    <Ctrl-D>

    Note: When entering a command name as the last item on the command line, a full path name must be given if the command is not in the current directory, and the at command will not accept any arguments.
  2. To run the uuclean command at 3:00 in the afternoon on the 24th of January, enter any one of the following commands:

    echo   uuclean   |   at   3:00   pm   January   24
     
    echo   uuclean   |   at   3 pm   Jan   24
     
    echo   uuclean   |   at   1500   jan   24
  3. To have a job reschedule itself, invoke the at command from within the shell procedure by including code similar to the following within the shell file:

    echo   "ksh   shellfile"   |   at   now   tomorrow
  4. To list the jobs you have sent to be run later, enter:
    at -l
  5. To cancel a job, enter:
    at -r ctw.635677200.a
    This cancels job ctw.635677200.a. Use the at -l command to list the job numbers assigned to your jobs.

Files

/var/adm/cron/FIFO A named pipe that sends messages to the cron daemon when new jobs are submitted with the crontab or at commands.
/usr/bin/at Contains the at command.
/var/adm/cron Contains the main cron directory.
/var/adm/cron/at.allow Specifies the list of allowed users.
/var/adm/cron/at.deny Specifies the list of denied users.

/var/spool/cron/atjobs Contains the spool area directory for at.

Related Information

The atq command, atrm command, auditpr command, batch command, bsh command, kill command, ksh command, mail command, nice command, ps command, sh command, su command.

The cron daemon.

The environment file.

Auditing Overview in AIX 5L Version 5.2 Security Guide provides more information about audits and audit events.

Input and Output Redirection Overview in AIX 5L Version 5.2 System Management Guide: Operating System and Devices describes how the operating system processes input and output.

National Language Support Overview for Programming in AIX 5L Version 5.2 System Management Guide: Operating System and Devices explains collating sequences, equivalence classes, and locale.

Shells Overview in AIX 5L Version 5.2 System User's Guide: Operating System and Devices describes what shells are, the different types of shells, and how shells affect the way commands are interpreted.

[ Top of Page | Previous Page | Next Page | Contents | Index | Library Home | Legal | Search ]