La commande 'at' permet de soumettre des travaux à un moment précis, sans passer par la crontab.
Exemple :
echo "<command>" | at now # Cela lance la commande en arrière plan, vous permettant de fermer la session.
at now +2 mins
banner hello > /dev/pts/0
<ctrl-d> (A partir de maintenat + 2 minutes )
/var/adm/cron/at.deny Liste des utilisateurs ne pouvant utiliser la commande 'at'.
/var/adm/cron/at.allow Liste des utilisateurs autorisés à utiliser 'at'('root' inclus).
at -l Liste les travaux planifiés
atq [user] VListe les travaux des autres utilisateurs(Seul 'root' peut utiliser cette commande.)
at -r Annule le travail planifié.
atrm job Annule une programmation à partir de son numéro.
atrm user Annule les travaux 'at' d'un autre utilisteur( Uniquement pour 'root' ou pour son propre compte.
atrm Annule tous les travaux en cours lancés par l'utilisateur courant.
batch Soumission d'un travail en arrière plan, lorsque la charge machine est moins grande.
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 [ -v ] [ -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 what 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:
* The at.allow file and the at.deny file do not exist (allows root user only).
* The at.allow file exists but the user's login name is not listed in it.
* The at.deny file exists and the user's login name is listed in it.
If the at.allow file does not exist and the at.deny file does not exist, only users with root 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. At most, 60 jobs can be scheduled
in any given run queue at the granularity of one per second. If more jobs than can be handled are submitted,
for every job beyond 60, a file _at<pid> is created in /var/spool/cron/atjobs/ which can be safely deleted by
the end user.
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:
Item
Description
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:
* If the value of the YY digits is between 70 and 99, the value of the CC digits is assumed to be 19.
* If the value of the YY digits is between 00 and 37, the value of the CC digits is assumed to be 20.
* The default value of SS is 00.
For years between 2038 and 2105, specify year in the yyyy format.
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:
* am
* pm
* zulu
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:
* noon
* midnight
* now
* A for AM
* P for PM
* N for noon
* M for midnight
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
Item
Description
-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 or 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 batchjobs, 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.
-q g-z
Queues user defined queue jobs.
-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).
-v
Used with -l flag to show content of listed jobs.
Parameters
Item
Description
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:
* A + (plus sign) followed by a number and one of the following words:
* minute[s]
* hour[s]
* day[s]
* week[s]
* month[s]
* year[s]
* The special word next followed by a one of the following words:
* minute[s]
* hour[s]
* day[s]
* week[s]
* month[s]
* year[s]
Security
Auditing Events
If the auditing subsystem is properly configured and is enabled, the at command generates the following audit
record or event every time the command is run:
Event
Information
AT_JobAdd
Lists at jobs that were run, the time the task was completed, and the user who issued the command.
For more details about how to properly select and group audit events, and how to configure audit event data
collection, see Setting Up Auditing in Security.
Attention RBAC users and Trusted AIX users: This command can perform privileged operations. Only privileged
users can run privileged operations. For more information about authorizations and privileges, see Privileged
Command Database in Security. For a list of privileges and the authorizations associated with this command,
see the lssecattr command or the getcmdattr subcommand.
Exit Status
This command returns the following exit values:
Item
Description
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
Item
Description
/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.
Item
Description
/var/spool/cron/atjobs
Contains the spool area directory for at.