1.Dd September 18, 2023
2.Dt "AT" 1
3.Os
4.Sh NAME
5.Nm at ,
6.Nm batch ,
7.Nm atq ,
8.Nm atrm
9.Nd queue, examine or delete jobs for later execution
10.Sh SYNOPSIS
11.Nm at
12.Op Fl q Ar queue
13.Op Fl f Ar file
14.Op Fl mldbv
15.Ar time
16.Nm at
17.Op Fl q Ar queue
18.Op Fl f Ar file
19.Op Fl mldbv
20.Fl t
21.Sm off
22.Op Oo Ar CC Oc Ar YY
23.Ar MM DD hh mm Op . Ar SS
24.Sm on
25.Nm at
26.Fl c Ar job Op Ar job ...
27.Nm at
28.Fl l Op Ar job ...
29.Nm at
30.Fl l
31.Fl q Ar queue
32.Nm at
33.Fl r Ar job Op Ar job ...
34.Pp
35.Nm atq
36.Op Fl q Ar queue
37.Op Fl v
38.Pp
39.Nm atrm
40.Ar job
41.Op Ar job ...
42.Pp
43.Nm batch
44.Op Fl q Ar queue
45.Op Fl f Ar file
46.Op Fl mv
47.Op Ar time
48.Sh DESCRIPTION
49The
50.Nm at
51and
52.Nm batch
53utilities
54read commands from standard input or a specified file which are to
55be executed at a later time, using
56.Xr sh 1 .
57.Bl -tag -width indent
58.It Nm at
59executes commands at a specified time;
60.It Nm atq
61lists the user's pending jobs, unless the user is the superuser; in that
62case, everybody's jobs are listed;
63.It Nm atrm
64deletes jobs;
65.It Nm batch
66executes commands when system load levels permit; in other words, when
67the load average drops below _LOADAVG_MX times number of active CPUs,
68or the value specified in the invocation of
69.Nm atrun .
70.El
71.Pp
72The
73.Nm at
74utility allows some moderately complex
75.Ar time
76specifications.
77It accepts times of the form
78.Ar HHMM
79or
80.Ar HH:MM
81to run a job at a specific time of day.
82(If that time is already past, the next day is assumed.)
83As an alternative, the following keywords may be specified:
84.Cm midnight ,
85.Cm noon ,
86or
87.Cm teatime
88(4pm)
89and time-of-day may be suffixed with
90.Cm AM
91or
92.Cm PM
93for running in the morning or the evening.
94The day on which the job is to be run may also be specified
95by giving a date in the form
96.Ar \%month-name day
97with an optional
98.Ar year ,
99or giving a date of the forms
100.Ar DD.MM.YYYY ,
101.Ar DD.MM.YY ,
102.Ar MM/DD/YYYY ,
103.Ar MM/DD/YY ,
104.Ar MMDDYYYY ,
105or
106.Ar MMDDYY .
107The specification of a date must follow the specification of
108the time of day.
109Time can also be specified as:
110.Op Cm now
111.Cm \&+ Ar count \%time-units ,
112where the time-units can be
113.Cm minutes ,
114.Cm hours ,
115.Cm days ,
116.Cm weeks ,
117.Cm months
118or
119.Cm years
120and
121.Nm
122may be told to run the job today by suffixing the time with
123.Cm today
124and to run the job tomorrow by suffixing the time with
125.Cm tomorrow .
126.Pp
127The
128.Nm at
129utility also supports the
130.Tn POSIX
131time format (see
132.Fl t
133option).
134.Pp
135For both
136.Nm
137and
138.Nm batch ,
139commands are read from standard input or the file specified
140with the
141.Fl f
142option and executed.
143The working directory, the environment (except for the variables
144.Ev TERM ,
145.Ev TERMCAP ,
146.Ev DISPLAY
147and
148.Ev _ )
149and the
150.Ar umask
151are retained from the time of invocation.
152An
153.Nm
154or
155.Nm batch
156command invoked from a
157.Xr su 1
158shell will retain the current userid.
159The user will be mailed standard error and standard output from his
160commands, if any.
161Mail will be sent using the command
162.Xr sendmail 8 .
163If
164.Nm
165is executed from a
166.Xr su 1
167shell, the owner of the login shell will receive the mail.
168.Pp
169The superuser may use these commands in any case.
170For other users, permission to use
171.Nm
172is determined by the files
173.Pa _PERM_PATH/at.allow
174and
175.Pa _PERM_PATH/at.deny .
176.Pp
177If the file
178.Pa _PERM_PATH/at.allow
179exists, only usernames mentioned in it are allowed to use
180.Nm .
181In these two files, a user is considered to be listed only if the user
182name has no blank or other characters before it on its line and a
183newline character immediately after the name, even at the end of
184the file.
185Other lines are ignored and may be used for comments.
186.Pp
187If
188.Pa _PERM_PATH/at.allow
189does not exist,
190.Pa _PERM_PATH/at.deny
191is checked, every username not mentioned in it is then allowed
192to use
193.Nm .
194.Pp
195If neither exists, only the superuser is allowed use of
196.Nm .
197This is the default configuration.
198.Sh IMPLEMENTATION NOTES
199Note that
200.Nm
201is implemented through the
202.Xr cron 8
203daemon by calling
204.Xr atrun 8
205every five minutes.
206This implies that the granularity of
207.Nm
208might not be optimal for every deployment.
209If a finer granularity is desired, the
210.Pa /etc/cron.d/at
211file can be edited and will be read by the system crontab, from which
212the 
213.Ev SHELL 
214and 
215.Ev PATH
216environment variables are inherited. 
217.Sh OPTIONS
218.Bl -tag -width indent
219.It Fl q Ar queue
220Use the specified queue.
221A queue designation consists of a single letter; valid queue designations
222range from
223.Ar a
224to
225.Ar z
226and
227.Ar A
228to
229.Ar Z .
230The
231.Ar _DEFAULT_AT_QUEUE
232queue is the default for
233.Nm
234and the
235.Ar _DEFAULT_BATCH_QUEUE
236queue for
237.Nm batch .
238Queues with higher letters run with increased niceness.
239If a job is submitted to a queue designated with an uppercase letter, it
240is treated as if it had been submitted to batch at that time.
241If
242.Nm atq
243is given a specific queue, it will only show jobs pending in that queue.
244.It Fl m
245Send mail to the user when the job has completed even if there was no
246output.
247.It Fl f Ar file
248Read the job from
249.Ar file
250rather than standard input.
251.It Fl l
252With no arguments, list all jobs for the invoking user.
253If one or more
254job numbers are given, list only those jobs.
255.It Fl d
256Is an alias for
257.Nm atrm
258(this option is deprecated; use
259.Fl r
260instead).
261.It Fl b
262Is an alias for
263.Nm batch .
264.It Fl v
265For
266.Nm atq ,
267shows completed but not yet deleted jobs in the queue; otherwise
268shows the time the job will be executed.
269.It Fl c
270Cat the jobs listed on the command line to standard output.
271.It Fl r
272Remove the specified jobs.
273.It Fl t
274Specify the job time using the \*[Px] time format.
275The argument should be in the form
276.Sm off
277.Op Oo Ar CC Oc Ar YY
278.Ar MM DD hh mm Op . Ar SS
279.Sm on
280where each pair of letters represents the following:
281.Pp
282.Bl -tag -width indent -compact -offset indent
283.It Ar CC
284The first two digits of the year (the century).
285.It Ar YY
286The second two digits of the year.
287.It Ar MM
288The month of the year, from 1 to 12.
289.It Ar DD
290the day of the month, from 1 to 31.
291.It Ar hh
292The hour of the day, from 0 to 23.
293.It Ar mm
294The minute of the hour, from 0 to 59.
295.It Ar SS
296The second of the minute, from 0 to 60.
297.El
298.Pp
299If the
300.Ar CC
301and
302.Ar YY
303letter pairs are not specified, the values default to the current
304year.
305If the
306.Ar SS
307letter pair is not specified, the value defaults to 0.
308.El
309.Sh FILES
310.Bl -tag -width _ATJOB_DIR/_LOCKFILE -compact
311.It Pa _ATJOB_DIR
312directory containing job files
313.It Pa _ATSPOOL_DIR
314directory containing output spool files
315.It Pa /var/run/utx.active
316login records
317.It Pa _PERM_PATH/at.allow
318allow permission control
319.It Pa _PERM_PATH/at.deny
320deny permission control
321.It Pa _ATJOB_DIR/_LOCKFILE
322job-creation lock file
323.El
324.Sh EXAMPLES
325To run a job at 4pm three days from now, use:
326.Bd -literal -offset indent
327at 4pm + 3 days
328.Ed
329.Pp
330To run a job at 10:00am on July 31, use:
331.Bd -literal -offset indent
332at 10am Jul 31
333.Ed
334.Pp
335To run a job at 1am tomorrow, use:
336.Bd -literal -offset indent
337at 1am tomorrow
338.Ed
339.Pp
340.Sh SEE ALSO
341.Xr nice 1 ,
342.Xr sh 1 ,
343.Xr umask 2 ,
344.Xr atrun 8 ,
345.Xr cron 8 ,
346.Xr sendmail 8
347.Sh AUTHORS
348.An -nosplit
349At was mostly written by
350.An Thomas Koenig Aq Mt ig25@rz.uni-karlsruhe.de .
351The time parsing routines are by
352.An David Parsons Aq Mt orc@pell.chi.il.us ,
353with minor enhancements by
354.An Joe Halpin Aq Mt joe.halpin@attbi.com .
355.Sh BUGS
356If the file
357.Pa /var/run/utx.active
358is not available or corrupted, or if the user is not logged on at the
359time
360.Nm
361is invoked, the mail is sent to the userid found
362in the environment variable
363.Ev LOGNAME .
364If that is undefined or empty, the current userid is assumed.
365.Pp
366The
367.Nm at
368and
369.Nm batch
370utilities
371as presently implemented are not suitable when users are competing for
372resources.
373If this is the case, another batch system such as
374.Em nqs
375may be more suitable.
376.Pp
377Specifying a date past 2038 may not work on some systems.
378