Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Advertise on LowEndTalk.com
Micro-Tutorial: Schedule a One-Time Job
New on LowEndTalk? Please read our 'Community Rules' by clicking on it in the right menu!

Micro-Tutorial: Schedule a One-Time Job

raindog308raindog308 Administrator, Moderator
edited January 2013 in Tutorials

BuyVM is relocating from San Jose to and I need to shut down my KVM node cleanly before 9pm on Saturday. I could login and do it then but...laziness is a virtue.

I could put it in cron, but I only want it to execute once.

I've noticed everyone knows about cron, but fewer people know about at(1). 'at' is the way to schedule a one-time job.

Example of scheduling a shutdown at 11pm Friday:

# at 11pm friday
/sbin/shutdown -h now  
commands will be executed using /bin/ksh
job 1358578800.c at Fri Jan 18 23:00:00 2013
# atq
 Rank     Execution Date     Owner          Job       Queue
  1st   Jan 18, 2013 23:00   root       1358578800.c   c
#

Might look a little funky because it's OpenBSD, but the same would work on Linux. Linux will execute the commands using /bin/bash

'atq' is the command to display queued jobs
atrm allows you to remove a job (or at -r in some Unices)

There's also 'batch' which you can find on the at(1) man page - it executes jobs only when the system load level is below a certain threshold.

For LET support, please visit the support desk.

Comments

  • ive used cron before, the day of week, day of month and month combination doesnt happen too often, But yes at works well, There is also a version for windows

  • at is definitely an under-utilized command. I never see anyone mention it. Then again, it's usually more common that someone needs to do something repeatedly on a regular schedule, I guess.

  • I use at on my scripts where the next run schedule is dynamic. Depending on the results the script launches itself with at now + count time-units.

  • atd must be running though, for the "at" scheduling to work. It is usually pruned / stopped, so check it before relying on "at".

    -

Sign In or Register to comment.