DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 

at(C)


at, batch -- execute commands at a later time

Syntax

at [ -m ] [ -f file ] [ -q letter ] time [ date ] [ increment ]

at [ -m ] [ -f file ] [ -q letter ] -t [[CC]YY]MMDDhhmm.[SS]

at -r job-id ...

at -l [ job-id ... ]

at -l -q letter

batch

Description

The at and batch commands both accept one or more commands from the standard input to be executed at a later time. at and batch differ in the way the set of commands, or job, is scheduled: at allows you to specify a time when the job should be executed, while batch executes the job when the system load level permits. After a job is queued with either command, the program writes a job identifier (made up of alphanumeric characters plus the period), along with the time the job will execute, to standard error.

at takes the following arguments:


time
The time can be specified as 1, 2, or 4 digits. One- and two- digit numbers are taken to be hours, four digits to be hours and minutes. The time can alternately be specified as two numbers separated by a colon, meaning hour:minute. A suffix am or pm can be appended; otherwise a 24-hour clock time is understood. The suffix utc can be used to indicate Greenwich Mean Time (GMT). The special names noon, midnight, and now are also recognized.

date
An optional date can be specified as either a month name followed by a day number (and an optional year number preceded by a comma) or a day of the week (spelt in full or abbreviated to three characters). Two special ``days,'' today and tomorrow, are recognized. If no date is given, today is assumed if the given hour is greater than the current hour and tomorrow is assumed if it is less. If the given month is less than the current month (and no year is given), next year is assumed.

increment
The time and optional date arguments can be modified with an increment argument of the form +n units, where n is an integer and units is one of the following: minutes, hours, days, weeks, months, or years. The singular form is also accepted, and +1 unit can also be written next unit. Thus, legitimate commands include:

at 0815am Jan 24, 1995
at 0815am Jan 24
at 8:15am Jan 24
at now + 1 day
at 5 pm Friday next week


-r job-id ...
Removes the specified job or jobs previously scheduled by the at or batch command. job-id is a job identifier returned by at or batch. Unless you are root, you can only remove your own jobs.

-l [ job-id ... ]
Lists schedule times of specified jobs. If no job-ids are specified, lists all jobs currently scheduled for the invoking user. Unless you are root, you can only list your own jobs.

-q letter
Places the specified job in a queue denoted by letter, where letter is any lowercase letter from ``a'' to ``z''. The queue letter is appended to the job identifier. The following letters have special significance:

a
at queue

b
batch queue

c
cron queue

For more information on the use of different queues, see the queuedefs(F) manual page.


-m
Mail is sent to the invoking user even if the at job produces no output.

If -m is not used, the at job's standard output and standard error are mailed to the user, unless explicitly redirected.


-f file
Specifies the pathname of a file to use for the source of the at job (instead of stdin).

[[CC]YY]MMDDhhmm.[SS]
Alternative format for specifying time in 2 digit codes where:

CC
century

YY
year

MM
month

DD
day

hh
hours

mm
minutes

SS
seconds
batch takes no arguments; it submits a job for immediate execution at lower priority than an ordinary at job.

at and batch jobs are executed using sh(C). Standard output and standard error output are mailed to the user unless they are redirected elsewhere. The shell environment variables, current directory, umask, and ulimit are retained when the commands are executed. Open file descriptors, traps, and priorities are lost.

The shell environment for both at and batch can be defined in the file /usr/lib/cron/.proto. If the file /usr/lib/cron/.proto.a exists, at takes its environment from this file instead. If the file /usr/lib/cron/.proto.b exists, batch takes its environment from this file instead.

Users are permitted to use at and batch if their usernames (logins) appear in the file /usr/lib/cron/at.allow. If that file does not exist, the file /usr/lib/cron/at.deny is checked to determine if a given user should be denied access to at and batch. If neither file exists, only root is allowed to submit a job. If only the at.deny file exists, and it is empty, global usage is permitted. The allow/deny files consist of one username per line.

If the system is installed with C2 security (this is the default, unless the system administrator has relaxed the security), the user will also need the chmodsuid kernel privilege. For more information about system security and kernel privileges, see ``Using a secure system'' in Using a Secure System and ``Maintaining system security'' in Managing system security.

Exit values

at and batch return 0 on successful completion, or 1 if an error occurs.

Diagnostics

Complains about syntax errors and times out of range.

Examples

The simplest way to use at is to place a series of commands in a file, one per line, and execute these commands at a specified time with the following command:

at time < file

The following sequence can be used at a terminal to format the file infile using the nroff text formatter, and place the output in the file outfile.

batch
nroff infile > outfile
<Ctrl>d

The next example demonstrates redirecting standard error to a pipe (|), which is useful in a shell procedure. The file infile is formatted and the output placed in outfile, with any errors generated being mailed to user (output redirection is covered on the sh(C) manual page).

batch <<!
nroff infile2 > &1 > outfile | mail user
!

To have a job reschedule itself, invoke at from within the job. For example, if you want shellfile to run every Thursday, executing a series of commands and then rescheduling itself for the next Thursday, you can include code similar to the following within shellfile:

echo "sh shellfile" | at 1900 thursday next week

Limitations

A maximum limit of 500 outstanding at jobs is imposed.

The time taken to submit an at job increases exponentially with the number of job files in the /usr/spool/cron/atjobs spool area.

Authorizations

The behavior of these commands depend on the ``cron'' authorization in authorize(F). See subsystem(M) for details.

Files


/usr/lib/cron
main cron directory

/usr/lib/cron/at.allow
list of allowed users

/usr/lib/cron/at.deny
list of denied users

/usr/lib/cron/queuedefs
scheduling information

/usr/spool/cron/atjobs
spool area

/usr/lib/cron/.proto
at and batch environment information

/usr/lib/cron/.proto.a
at shell environment

/usr/lib/cron/.proto.b
batch shell environment

See also

cron(C), kill(C), mail(C), nice(C), ps(C), queuedefs(F), sh(C)

Standards conformance

at and batch are conformant with:

ISO/IEC DIS 9945-2:1992, Information technology - Portable Operating System Interface (POSIX) - Part 2: Shell and Utilities (IEEE Std 1003.2-1992);
AT&T SVID Issue 2;
X/Open CAE Specification, Commands and Utilities, Issue 4, 1992.


© 2005 The SCO Group, Inc. All rights reserved.
SCO OpenServer Release 6.0.0 -- 03 June 2005