The following sections describe how to use at to schedule jobs (commands and scripts) for execution at a later time, how to display and remove these jobs, and how to control access to at.
By default, users can create, display, and remove their own at job files. To access at files belonging to root or other users, you must have superuser privileges.
When you submit an at job, it is assigned a job identification number along with the .a extension that becomes its file name.
Submitting an at job file includes:
Invoking the at utility, specifying a command execution time.
Entering a command or script to execute later.
If output from this command or script is important, be sure to direct it to a file for later examination.
For example, the following at job removes core files from the user account belonging to Smith near midnight on the last day of January.
$ at 11:45pm January 31 at> rm /home/smith/*core* at> Press Control-d job 852755100.a at Wed Jan 8 13:25:00 1997 |
You can set up a file to control access to the at command, permitting only specified users to create, remove, or display queue information about their at jobs. The file that controls access to at, /etc/cron.d/at.deny, consists of a list of user names, one per line. The users listed in this file cannot access at commands.
The at.deny file, created during SunOS software installation, contains the following user names:
daemon bin smtp nuucp listen nobody noaccess |
With superuser privileges, you can edit this file to add other user names whose at access you want to restrict.
Enter the at facility, specifying the time you want your job executed, and press Return.
$ at [-m] time [date] |
-m |
Sends you mail after the job is completed. |
time |
Hour that you want to schedule the job. Add am or pm if you do not specify the hours according to a 24-hour clock. midnight, noon, and now are acceptable keywords. Minutes are optional. |
date |
First three or more letters of a month, a day of the week, or the keywords today or tomorrow. |
At the at prompt, enter the commands or scripts you want to execute, one per line. You may enter more than one command by pressing Return at the end of each line.
Exit the at utility and save the at job by pressing Control-d.
Your at job is assigned a queue number, which is also its file name. This number is displayed when you exit the at utility.
The following example shows the at job that user jones created to remove her backup files at 7:30 at night. She used the -m option so that she would receive a mail message after her job completed.
$ at -m 1930 at> rm /home/jones/*.backup at> Press Control-d job 852777000.a at Wed Jan 8 19:30:00 1997 |
She received a mail message which confirmed the execution of her at job.
Your "at" job "rm /home/jones/*.backup" completed. |
The following example shows how Jones scheduled a large at job for 4:00 Saturday morning. The output of which was directed to big.file.
$ at 4 am Saturday at> sort -r /usr/dict/words > /export/home/jones/big.file |
To check your jobs that are waiting in the at queue, use the atq command. This command displays status information about the at jobs that you created.
$ atq |
To verify that you have created an at job, use the atq command. The atq command confirms that at jobs belonging to jones have been submitted to the queue.
$ atq Rank Execution Date Owner Job Queue Job Name 1st Jan 8, 1997 13:25 jones 852755100.a a stdin 2nd Jan 8, 1997 19:30 jones 852777000.a a stdin 3rd Jan 11, 1997 04:00 jones 858142000.a a stdin |
To display information about the execution times of your at jobs, use the at -l command.
$ at -l [job-id] |
-l job-id |
Identification number of the job whose status you want to examine. |
The following example shows output from the at -l command, used to get status information on all jobs submitted by a user.
$ at -l 852755100.a Wed Jan 8 13:25:00 1997 852777000.a Wed Jan 8 19:30:00 1997 858142000.a Sat Jan 11 04:00:00 1997 |
The following example shows output displayed when a single job is specified with the at -l command.
$ at -l 858142000.a 858142000.a Sat Jan 11 04:00:00 1996 |
(Optional) To remove an at job belonging to root or another user, become superuser.
Remove the at job from the queue before it is executed.
$ at -r [job-id] |
-r job-id |
Identification number of the job you want to remove. |
Verify the at job is removed by using the at -l (or the atq) command to display the jobs remaining in the at queue. The job whose identification number you specified should not appear.
$ at -l [job-id] |
In the following example, a user wants to remove an at job that was scheduled to execute at noon on March 1. First, the user displays the at queue to locate the job identification number. Next, the user removes this job from the at queue. Finally, the user verifies that this job has been removed from the queue.
$ at -l 852755100.a Wed Jan 8 13:25:00 1997 852777000.a Wed Jan 8 19:30:00 1997 858142000.a Sat Jan 11 04:00:00 1997 $ at -r 858142000.a $ at -l 858142000.a at: 858142000.a does not exist |