The Single UNIX ® Specification, Version 2
Copyright © 1997 The Open Group


batch - execute commands when the system load permits




The batch utility reads commands to be executed at a later time. It is the equivalent of the command:

at -q b -m now

where queue b is a special at queue, specifically for batch jobs. Batch jobs will be submitted to the batch queue with no time constraints and run by the system using algorithms, based on unspecified factors, that may vary with each invocation of batch.

Users are permitted to use batch if their name appears 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 the user should be denied access to batch. If neither file exists, only a process with the appropriate privileges is allowed to submit a job. If only at.deny. exists and is empty, global usage is permitted. The at.allow and at.deny files consist of one user name per line.






The standard input must be a text file consisting of commands acceptable to the shell command language described in Shell Command Language . The standard input will only be used if no -f file option is specified.


The text files /usr/lib/cron/at.allow and /usr/lib/cron/at.deny contain user names, one per line, of users who are, respectively, authorised or denied access to the at and batch utilities.


The following environment variables affect the execution of batch:
Provide a default value for the internationalisation variables that are unset or null. If LANG is unset or null, the corresponding value from the implementation-dependent default locale will be used. If any of the internationalisation variables contains an invalid setting, the utility will behave as if none of the variables had been defined.
If set to a non-empty string value, override the values of all the other internationalisation variables.
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).
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.
Determine the format and contents for date and time strings written by batch.
Determine the location of message catalogues for the processing of LC_MESSAGES .
Determine the 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; any of the preceding accompanied by a warning diagnostic about which was chosen.
Determine the timezone. The job will be submitted for execution at the time specified by 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.




When standard input is a terminal, prompts of unspecified format for each line of the user input described in the STDIN section may be written to standard output.

In the POSIX locale, the following will be written to the standard output for each job when jobs are listed in response to the -l option:

"%s\t%s\n", at_job_id, <date> where <date> is equivalent in format to the output of:

date +"%a %b %e %T %Y"

The date and time written will be adjusted so that they appear in the timezone of the user (as determined by the TZ variable).


The following will be written to standard error when a job has been successfully submitted:

"job %s at %s\n", at_job_id, <date> where <date> will have the same format as is described in the STDOUT section. Neither this, nor warning messages concerning the selection of the command interpreter, are considered a diagnostic that changes the exit status.

Diagnostic messages, if any, are written to standard error.






The following exit values are returned:
Successful completion.
An error occurred.


The job will not be scheduled.


It may be useful to redirect standard output within the specified commands.


  1. This sequence can be used at a terminal:
    sort < file >outfile

  2. This sequence, which demonstrates redirecting standard error to a pipe, is useful in a command procedure (the sequence of output redirection specifications is significant):
    batch <<!
    diff file1 file2 2>&1 >outfile | mailx mygroup





UNIX ® is a registered Trademark of The Open Group.
Copyright © 1997 The Open Group
[ Main Index | XSH | XCU | XBD | XCURSES | XNS ]