pavement

At

From FreeBSDwiki
(Difference between revisions)
Jump to: navigation, search
(September is month number 9, not 10.)
Line 18: Line 18:
 
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:
 
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 &'''
+
  ph34r#''' cvsup /usr/share/examples/cvsup/ports-supfile
 
+
However, if started that way the job is still a [[child process]] of your shell, and thus will die a sudden death if you choose to log out before it is done.
+
 
+
Access to either [[cron]] or the '''at''' scheduler may be open to all users or restricted only to certain users at the system administrator's discretion.  Also, it is worth noting that by default the system only queues up '''at''' jobs once every five minutes, so don't be confused if '''at now''' doesn't produce immediate results.
+
 
+
[[Category:System Commands]]
+

Revision as of 00:45, 17 June 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
Personal tools