These classnotes are depreciated. As of 2005, I no longer teach the classes. Notes will remain online for legacy purposes

UNIX01/Run At

Classnotes | UNIX01 | RecentChanges | Preferences

Difference (from prior major revision) (no other diffs)

Removed: 38d37
2 2003-08-11 16:00 a sam

The at suite is a must less featureful sheduling system than cron. Thus, it is generally easier to use, but will only perform a subset of what cron can do.

The basic usage of at is to specify a sequence of commands (or a shell script) which are then run at a later time (by invoking /bin/sh). It is usaully for quickly setting up a "one-time" event, and not for reoccuring events.

The basic at suite is as follows:

 at [options] [-f file] TIME
 atq [-q queue]
 atrm job [job...]

at accepts times of the form HH:MM to run a job at a specific time of day. (If that time is already past, the next day is assumed.) You may also specify midnight, noon, or teatime (4pm) and you can have a time-of-day suffixed with AM or PM for running in the morning or the evening. You can also say what day the job will be run, by giving a date in the form month-name day with an optional year, or giving a date of the form MMDDYY or MM/DD/YY or DD.MM.YY. The specification of a date must follow the specification of the time of day. You can also give times like now + count time-units, where the time-units can be minutes, hours, days, or weeks and you can tell at to run the job today by suffixing the time with today and to run the job tomorrow by suffixing the time with "tomorrow".

For example, to run a job at 4pm three days from now, you would do

 at 4pm + 3 days

To run a job at 10:00am on July 31, you would do

 at 10am Jul 31

and to run a job at 1am tomorrow, you would do

 at 1am tomorrow

If called without the "-f" option, at reads in commands from STDIN (the command line or a pipe) until an EOF or termination character is reached. In this way, you can use it as a simple means to capture keystrokes to be ran later.

If you, instead, have a shell script which contains a sequence of commands, you can have at use that script by specifying it with the "-f" option. For example, if I had the script "mirror_website.sh", and I wanted it to run at midnight on August 24th, my at command would be

 $ at -f mirror_website.sh midnight Aug 24

To list the current jobs in your queue, you use the "atq" command.

 sam@rygel:~/work/programs/temp$ atq
 1       2003-08-31 00:00 a sam
 2       2003-08-11 16:00 a sam

You can also remove any scheduled job using the "atrm" command. You can specify as many jobs to remove as you want, all specified by their job numbers. For example, if I wanted to remove the second job from my above queue, I would execut

 sam@rygel:~/work/programs/temp$ atrm 2

 sam@rygel:~/work/programs/temp$ atq
 1       2003-08-31 00:00 a sam


Classnotes | UNIX01 | RecentChanges | Preferences
This page is read-only | View other revisions
Last edited August 9, 2003 1:36 am (diff)
Search:
(C) Copyright 2003 Samuel Hart
Creative Commons License
This work is licensed under a Creative Commons License.