[TriLUG] Scheduling a command to run later, once

Jeremy Portzer jeremyp at pobox.com
Fri Jun 6 19:41:39 EDT 2003


Someone asked this on IRC today but left before I noticed.

The question was how to schedule an automatic reboot in the future.  The
solution given was to use "nohup" with shutdown, since you can tell
shutdown what time to shutdown.  This is nice becauase the running
"shutdown" process will send out messages reminding any logged-in users
that the system will be going down.

However, if you're dealing with a command that doesn't have the built-in
facility specify the time to run, the "at" command allows you to
schedule jobs.  For example:
bash$ at 20:00
at> ls
at> <EOT>
job 1 at 2003-06-06 20:00
bash$

That will run the command "ls" at 20:00 (8:00 pm).  The output will be
mailed to the user, just like cron.  But it's a little faster to set up
then a crontab if you just want to run a command once.

The at command requires the "atd" daemon to be running; this daemon is
installed and turned on by default in most Linux distributions.

There are some other nice functions in "at" that allow you manage jobs
that have been queued but not executed yet; see the at(1) man page.

Hope this helps!

Jeremy Portzer





More information about the TriLUG mailing list