At
Revision as of 13:04, 18 September 2007
The at scheduler is used to schedule a job for one-time-only running at a later date. For comparison, the cron scheduler is used to schedule jobs for repeated execution at regular intervals. One very handy use of the at scheduler is to schedule lengthy jobs to run in the background immediately - that way even if you need to (or are forced to) close your shell session, your job will continue running.
The basic syntax of at is to type at followed by a time (specified in POSIX time format) you wish your new job to be executed. Examples would be "at now" to run the job immediately, "at 0400" to run the job at 4 AM today, or "at 200409282300" to run the job at 11:00 PM on September 28th of 2004. Once this is done, you enter interactive mode, and any further commands you type will be part of the at job scheduled. Once you're done entering in commands to be scheduled, you press CTRL-D (aka the eof character) and the scheduler tells you what your job number is and what shell it will be executed with (typically /bin/sh by default).
ph34r# at now cvsup /usr/share/examples/cvsup/ports-supfile [user presses CTRL-D] Job 3 will be executed using /bin/sh ph34r#
You may also use the -f option to specify a file that contains the list of commands you wish to process - for example:
ph34r# echo "cvsup /usr/share/examples/cvsup/ports-supfile" > at-job.txt ph34r# at -f at-job.txt now Job 5 will be executed using /bin/sh ph34r#
If all you want to do is force a job started from the shell into the background, you can do that without using at simply by adding an ampersand to the end of your command line - for example:
ph34r# cvsup /usr/share/examples/cvsup/ports-supfile