Your Browser is not longer supported

Please use Google Chrome, Mozilla Firefox or Microsoft Edge to view the page correctly
Loading...

{{viewport.spaceProperty.prod}}

batch - execute commands at a later time

&pagelevel(4)&pagelevel

batch reads commands from standard input, puts them in a queue, and executes them when system load level permits.

Standard output and standard error output of the commands to be executed are sent to the user by mailx unless they are redirected elsewhere. The environment variables, the current directory, the permissions for new files (see umask) and the maximum permissible file size (see ulimit) are retained, but open files and priorities are lost, and the trap command (shell built-in for catching signals) is deactivated.

batch writes the job number and the schedule time to standard error.

Jobs scheduled with batch 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.

batch has exactly the same effect as at -qb with no further options.

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 batch if your login name appears in it.

If the file /usr/lib/cron.d/at.allow does not exist, you can only use batch 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 batch.

If only an empty deny file exists, for example, everyone is allowed to use batch.

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.

Syntax


batch
command ...
CTRL
+D or @@d

command

Any command or shell script. You can specify more than one command at a time, using semicolons or newlines to separate them. The resulting command list is executed under a single job number.

Error

at: you are not authorized to use at. Sorry.

Permission to use batch denied (see “Before the call”).

File

/usr/lib/cron.d/at.allow

List of login names with permission to use batch. One login name is entered per line.

/usr/lib/cron.d/at.deny

List of login names explicitly denied permission to use batch. One login name is entered per line.

/var/spool/cron/atjobs

Directory containing a separate file for each batch job which has not yet been executed. Each batch job is allocated a file of its own with the file name jobnumber.b.

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 batch:

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.

LC_TIME

Determine the format and contents for date and time strings written by batch.

NLSPATH

Determine the location of message catalogs for the processing of LC_MESSAGES.

Example

In the following example, the standard input is redirected, and batch takes its work from the file jobs:

$ batch < jobs

job 604763316.b at Mon Mar 9 14:48:36 2009

The jobs contained in the file jobs are run in sequential order as background processes by batch. When the job is complete, you can have the result displayed on the screen by mailx.

See also

at, crontab, mailx, ulimit