At
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 &
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.
at, on the other hand, will work as a tool to fire up a job without it being a child process of the shell:
ph34r# at now echo test > /home/jimbo/test.txt ^D (user pressed control-D) Job 14 will be executed using /bin/sh ph34r# atq Date Owner Queue Job# Fri Feb 29 12:01:00 EST 2008 root c 14 ph34r# date Fri Feb 29 12:01:29 EST 2008
OK, the job is in the queue - but it won't actually run until 12:05, since cron only fires up atrun once every 5 minutes. What if we don't want to wait? We can just run atrun manually! (Note: atrun probably will not be in your PATH, so you'll need to specify the full path to run it.)
ph34r# /usr/libexec/atrun ph34r# atq ph34r# date Fri Feb 29 12:01:53 EST 2008 ph34r# cat /home/jimbo/test.txt test ph34r#
As we can see, the job popped out of the queue and ran successfully when we fired up atrun manually. Knowing how to do this can save you a lot of frustration when you want to queue long running jobs up and make sure they're actually running before you close your shell and go somewhere else.
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.
Contents |
Paths Are Made By Walking
2012s Baccalaureate speaker at the University of Pennsylvania was an unconventional choice for an Ivy League school. To address their newly-minted graduates, aspiring to dazzling careers, they picked a man who has never in his adult life, applied for a job. A man who hasnt worked for pay in nearly a decade, and whose self-stated mission is simply "to bring smiles to the world and stillness to my heart".
[Paths Are Made By Walking]
[GoodvilleNews.com - good, positive news, inspirational stories, articles]
9 Essential Skills Kids Should Learn
Kids in todays school system are not being prepared well for tomorrows world.As someone who went from the corporate world and then the government world to the ever-changing online world, I know how the world of yesterday is rapidly becoming irrelevant.
[9 Essential Skills Kids Should Learn]
[GoodvilleNews.com - good, positive news, inspirational stories, articles]
Authors Nominate Top Books of All Time
In 2002, the Norwegian Book Clubs gathered 100 authors from 54 countries and asked each one to list the 10 best works of fiction of all time. The authors responded and this list was created. The titles are arranged alphabetically by author name, so no one book stands above any other. The following list is the groups selection of the worlds 100 best books.How many have you read?
[Authors Nominate Top Books of All Time]
[GoodvilleNews.com - good, positive news, inspirational stories, articles]
Would Gandhi Use Social Media?
If Gandhi were alive today, would he use social media? He was never anti-technology, or even anti-changing with the times. Quite the opposite, actually. If Internet technologies and social networks were around, he would certainly have embraced them -- but with a conscious mindfulness of their strengths and weaknesses.
[Would Gandhi Use Social Media?]
[GoodvilleNews.com - good, positive news, inspirational stories, articles]
New Toilet System Transform Waste into Electricity
Scientists from Nanyang Technological University (NTU) have invented a new toilet system that will turn human waste into electricity and fertilisers and also reduce the amount of water needed for flushing by up to 90 per cent compared to current toilet systems in Singapore.
[New Toilet System Transform Waste into Electricity]
[GoodvilleNews.com - good, positive news, inspirational stories, articles]