Jump to content United States-English
HP.com Home Products and Services Support and Drivers Solutions How to Buy
» Contact HP
More options
HP.com home
HP-UX Reference > A

at(1)

HP-UX 11i Version 3: February 2007
» 

Technical documentation

» Feedback
Content starts here

 » Table of Contents

 » Index

NAME

at, batch — execute batched commands immediately or at a later time

SYNOPSIS

Enter commands from standard input to run at a specified time:

at [-m] [-q queue] -t spectime

commands eof

at [-m] [-q queue] time [date] [next timeunit | +count timeunit]

commands eof

Enter commands from a file to run at a specified time:

at -f job-file [-m] [-q queue] -t spectime

at -f job-file [-m] [-q queue] time [date] [next timeunit | +count timeunit]

List scheduled jobs:

at -d job-id ...

at -l [job-id ...]

at -l -q queue

Cancel (remove) a scheduled job:

at -r job-id ...

Enter commands from standard input to run as a batch process:

batch commands eof

Enter commands from a file to run as a batch process:

batch < job-file

DESCRIPTION

The at and batch commands schedule jobs for execution by the cron daemon (see cron(1M)).

at schedules a job for execution at a specified time. at can also list (-l) or remove (-r) existing scheduled at and batch jobs.

batch schedules a job for execution immediately, or as soon as system load levels permit.

You can enter commands into a job in one of the following ways:

  • From the keyboard on separate lines immediately after the at or batch command line, followed by the currently defined eof (end-of-file) character to end the input. The default eof is Ctrl-D. It can be redefined in your environment (see stty(1)).

  • With the -f option of the at command to read input from a script file.

  • From output piped from a preceding command.

Options and Arguments

at recognizes the following options and arguments.

commands

One or more HP-UX commands that can be executed as a shell script by at or batch.

eof

End-of-file character. The default is Ctrl-D unless defined otherwise in your environment.

job-file

The path name of an existing file.

job-id

The job identifier reported by at or batch when the job was originally scheduled.

-d job-id ...

Displays the contents of the specified job. An unprivileged user is restricted to display information only on jobs that the user owns. A user with the appropriate privileges is able to display information about all jobs.

-f job-file

Read in the commands contained in job-file instead of using standard input.

-l [job-id ...]

List the jobs specified. If no job-ids are given, all jobs are listed.

-m

Send mail to the invoking user after the job has run, announcing its completion. Unless redirected elsewhere within the job, standard output and standard error produced by the job are automatically mailed to the user as well.

-q queue

Submit the specified job to the queue indicated (see queuedefs(4)). Queues a, b, and d through y can be used. at uses queue a by default. batch always uses queue b. All queues except b require a time or a -t specification. at -qb is equivalent to batch. When used with the -l option, limit the search to that particular queue.

-r job-id ...

Remove the jobs specified by each job-id.

-t spectime

Define the absolute time to start the job.

spectime

A date and time in the format:

[[CC]YY]MMDDhhmm[.ss]

where the decimal digit pairs are as follows:

CC

The first two digits of the year (19, 20).

YY

The second two digits of the year (69-99, 00-68). See WARNINGS.

MM

The month of the year (01-12).

DD

The day of the month (01-31).

hh

The hour of the day (00-23).

mm

The minute of the hour (00-59).

ss

The second of the minute (00-61).

If both CC and YY are omitted, the default is the current year.

If CC is omitted and YY is in the range 69-99, CC defaults to 19. Otherwise, CC defaults to 20.

The range for ss provides for two leap seconds. If ss is 60 or 61, and the resulting time, as affected by the TZ environment variable, does not refer to a leap second, the time is set to the whole minute following mm.

If ss is omitted, it defaults to 00.

time [date]

Define the base time for starting the job.

time

A time specified as one, two, or four digits. One- and two-digit numbers represent hours; four digits represent hours and minutes.

Alternately, time can be specified as two numbers separated by a colon (:), a single quote ('), the letter h (h), a period (.), or a comma (,). Spaces may be present between the separator and digits representing minutes. If defined in langinfo(5), special time unit characters can be used.

am or pm can be appended to indicate morning or afternoon. Otherwise, a 24-hour clock is understood. For example, 0815, 8:15, 8'15, 8h15, 8.15, and 8,15 are read as 15 minutes after eight in the morning. The suffixes zulu and utc can be used to specify Coordinated Universal Time (UTC), equivalent to Greenwich Mean Time (GMT).

The special names midnight, noon, and now are also recognized.

date

A day of the week (fully spelled out or abbreviated) or a date consisting of a day, a month, and optionally a year. The day and year fields must be numeric, and the month can be either fully spelled out, abbreviated, or numeric. The fields in the date string are separated by punctuation marks such as slash (/), hyphen (-), period (.), and comma (,). If defined in langinfo(5), special date unit characters can be present. A field having a value greater than 31 is treated as the year field and the remaining two fields in the date string are treated as month and day fields. Otherwise, if a given date is ambiguous (such as 2/5 or 2/5/10), the D_T_FMT string (if defined in langinfo(5)) is used to resolve the ambiguity.

Two special days, today and tomorrow, are also recognized. If no date is given, today is assumed if the given time is greater than the current time; 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. Two-digit years in the range 69 to 99 are expanded to 1969 to 1999; in the range 00 to 68, to 2000 to 2068.

next timeunit | + count timeunit

Delay the execution date and time by a specific number of time units after the base time specified by time [date].

count

A decimal number. next is equivalent to +1.

timeunit

A time unit, one of the following: minutes, hours, days, weeks, months, or years, or their singular forms.

How Jobs Are Processed

When a job is accepted, at and batch print a message to standard error in the form:

job job-id at execution-date

where job-id is the job identifier in the form jobnumber.queue, such as 756284400.a, and execution-date is the date and time when the job will be released for execution.

If your login shell is not the POSIX shell (/usr/bin/sh), the commands also print a warning message:

warning: commands will be executed using /usr/bin/sh

at jobs default to queue a. batch jobs always go in queue b. See the -q option.

An at or batch job consists of a two-part script stored in /var/spool/cron/atjobs that can be executed by the POSIX shell.

The first part sets up the environment to match the environment when the at or batch command was issued. This includes the current shell environment variables, current directory, umask, and ulimit (see ulimit(2), umask(1), and proto(4)). Open file descriptors, traps, and priority are lost.

The second part consists of the commands that you entered.

When cron dispatches the job, it starts a POSIX shell to execute the script.

The number of jobs executing from a queue at any time is controlled by parameters in the file /var/adm/cron/queuedefs (see queuedefs(4)).

Standard output and standard error from the job are mailed to the user unless they are redirected elsewhere within the job.

Scheduled jobs are immune to the SIGHUP hangup signal, and remain scheduled if the user logs off.

Users are permitted to use the at and batch commands if their user names appear in the file /usr/lib/cron/at.allow. If that file does not exist, users can use at and batch if their names do not appear in the file /usr/lib/cron/at.deny. If neither file exists, only superuser is allowed to submit jobs. If only at.deny exists but is empty, all users can use at and batch. The allow/deny files consist of one user name per line.

All users can list and remove their own jobs. Users with appropriate privileges can list and remove jobs other than their own.

Notes

The batch command requests a unique job-id for each batch job it schedules. The maximum number of tries to request a unique job-id is restricted to 100. If not successful after 100 tries, the batch command exits with the message queue full. You can configure this number by setting the variable BATCH_MAXTRYS=value in the /etc/default/cron file. The value of BATCH_MAXTRYS can be any positive number or the string INFINITE (the default value). If the value is set to INFINITE, batch requests a unique job-id until it successfully receives one.

The at command can schedule only one job per queue for a given time. If a job is already scheduled for a given time, the at command schedules the new job for the next second. You can remove this limitation by setting the variable MULTI_JOB_SUPPORT to 1 in the /etc/default/cron file. If MULTI_JOB_SUPPORT is set to 1, then at supports scheduling multiple jobs for the same time and creates the job-id in the form jobnumber.queue.index , where index is the total number of jobs scheduled for the given time. You can disable this feature by setting the variable MULTI_JOB_SUPPORT to 0.

Security Restrictions

If the compartmentalization feature is enabled, cron and at invoke the jobs from the compartment that the jobs were created from. Note that at creates the job files in /var/spool/cron/atjobs. Hence, if the at command is invoked from a compartment which has no write access to this directory and which disallows the COMMALLOWED privilege, at fails to schedule the jobs. See compartments(5) and privileges(5) for more information.

EXTERNAL INFLUENCES

Environment Variables

LC_TIME determines the format and contents of date and time strings.

LC_MESSAGES determines the language in which messages are displayed.

LC_MESSAGES also determines the language in which the words days, hours, midnight, minutes, months, next, noon, now, today, tomorrow, weeks, years, and their singular forms can also be specified.

IF LC_TIME or LC_MESSAGES is not specified in the environment or is set to the empty string, the value of LANG is used as a default for each unspecified or empty variable. If LANG is not specified or is set to the empty string, a default of "C" (see lang(5)) is used instead of LANG.

If any internationalization variable contains an invalid setting, all internationalization variables default to "C" (see environ(5)).

International Code Set Support

Single- and multi-byte character code sets are supported.

RETURN VALUE

The exit code is set to one of the following:

0

Successful completion

1

Failure

DIAGNOSTICS

at produces self-explanatory messages for syntax errors and out-of-range times.

warning: commands will be executed using /usr/bin/sh

  • If your login shell is not the POSIX shell (/usr/bin/sh), at and batch produce a warning message as a reminder that at and batch jobs are executed using /usr/bin/sh.

EXAMPLES

The following commands show three different ways to run a POSIX shell script file named delayed-job five minutes from now:

at -f delayed-job now + 5 minutes cat delayed-job | at now + 5 minutes at now + 5 minutes <delayed-job

Run a typical HP-UX command (nroff in this case) when system load levels permit, and redirect standard output and standard error to files:

batch nroff source-file >output-file 2>error-file eof (the default is Ctrl-D)

Run a job contained in future in the home directory at 12:20 a.m. on December 27, 2013:

at -f $HOME/future -t201312271220.00

Redirect standard error to a pipe (useful in a shell procedure). Note that the sequence of the output redirection specifications is significant. Standard error is redirected to where standard output is going; standard output is redirected to a file; the original "standard output" (which now consists of the former standard error) is piped to the mail program.

batch <<!! (sets eof temporarily to !!) nroff input-file 2>&1 1> output-file | mail loginid !!

Run a job contained in jobfile in the home directory at 5:00 a.m. next Tuesday:

at -f $HOME/jobfile 5am tuesday next week

Run the same job at 5:00 a.m. one week from next Tuesday (i.e., 2 Tuesdays in advance):

at -f $HOME/jobfile 5am tuesday + 2 weeks

Add a command to the file named weekly-run in directory jobs in the home directory so that it automatically reschedules itself every time it runs. This example reschedules itself every Thursday at 1900 (7:00 p.m.):

echo "sh $HOME/jobs/weekly-run" | at 1900 thursday next week

The following commands show several forms recognized by at and include native language usage:

at 0815 Jan 24 at 8:15 Jan 24 at 9:30am tomorrow at now + 1 day at -f job 5 pm Friday at 17:40 Tor. # in Danish at 17h46 demain # in French at 5:30 26. Feb. 1988 # in German at 12:00 26-02 # in Finnish

WARNINGS

If the date argument begins with a number and the time argument is also numeric without a suffix, the time argument should be a four-digit number that can be correctly interpreted as hours and minutes.

If you use both next and +count within a single at command, the first operator is accepted and the trailing operator is silently ignored.

If you use both -t and time ... in the same command, the first specified is accepted and the second is silently ignored.

If the FIFO used to communicate with cron fills up, at is suspended until cron has read sufficient messages from the FIFO to make room for the message at is trying to write. This condition can occur if at is writing messages faster than cron can process them or if cron is not executing.

Scheduled processes are run in the background. Any script file that calls itself will cause the user or the system to run out of available processes.

If the execution-time request for a job duplicates the execution time of a currently scheduled job, the new job time is set to the next available second.

at will not schedule jobs whose start time precedes the current Epoch (00:00:00 January 1, 1970 UTC). at will not schedule jobs beyond the year 2037.

DEPENDENCIES

HP Process Resource Manager

If the optional HP Process Resource Management (PRM) software is installed and configured, jobs are launched in the initial process resource group of the user that scheduled the job. The user's initial group is determined at the time the job is started, not when the job is scheduled. If the user's initial group is not defined, the job runs in the user default group (PRMID=1). See prmconfig(1) for a description of how to configure HP PRM, and prmconf(4) for a description of how the user's initial process resource group is determined.

AUTHOR

at was developed by AT&T and HP.

FILES

/etc/default/cron

Configuration file

/usr/bin/sh

POSIX shell

/usr/lib/cron/at.allow

List of allowed users

/usr/lib/cron/at.deny

List of denied users

/var/adm/cron

Main cron directory

/var/adm/cron/.proto

This file contains a set of shell commands which are added to the at job file to make the environment for the at job same as the current environment. See proto(4).

/var/adm/cron/queuedefs

Scheduling information

/var/spool/cron/atjobs

Spool area

SEE ALSO

crontab(1), kill(1), mail(1), nice(1), ps(1), sh(1), stty(1), cron(1M), proto(4), queuedefs(4), compartments(5), privileges(5).

HP Process Resource Manager: prmconfig(1), prmconf(4) in HP Process Resource Manager User's Guide.

STANDARDS CONFORMANCE

at: SVID2, SVID3, XPG2, XPG3, XPG4

batch: SVID2, SVID3, XPG2, XPG3, XPG4

Printable version
Privacy statement Using this site means you accept its terms Feedback to webmaster
© 1983-2007 Hewlett-Packard Development Company, L.P.