Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

Are jobs scheduled with 'at' persistent across reboots? Also, anyone know of a way the jobs could be backed up without access to the relevant spool directories?

I want to send an email at specified intervals from now up to a year ( ie 1 week, 1 month, 6 months) so this seems like a good tool, maybe there is a better one?

share|improve this question
add comment

3 Answers

up vote 4 down vote accepted

Yes they are persistent across reboots (they're just files in a spool).

Regarding having access to them, as a regular user you won't have access to the files, but you could build a system to back them up. Maybe something like this:

MYAT=~/atjobs

/bin/rm -rf $MYAT/*

at -l >$MYAT/JOBS
for j in `cat $MYAT/JOBS | cut -f1`
do
  at -c $j >$MYAT/$i
done

If you needed to reload the job later:

for j in `cat $MYAT/JOBS | cut -f1`
do
  # make sure the job isn't defined
  atrm $j
  # reload it from the file
  at -f $MYAT/$j `grep ^$j $MYAT/JOBS | awk '{ print $3, $2 }'`
done

(this is all mostly untested. The basic command are right but there's sure to be a bug in the logic in there somewhere)

Having said all that though, I'm not sure I'd use at for the task you describe. I'd probably use a preexisting calendaring system. Failing that though, I would user a cron job that ran daily that checked a file to see if there were any messages to send. Much more portable than at jobs, and much more likely to be remembered if you switch machines...

share|improve this answer
    
I see how that backs up the jobs, but how would I reload all those jobs if needed? –  Kyle Brandt May 27 '09 at 13:47
add comment

I've not used the at command much, but I have used cron to schedule tasks to be executed, and it is persistent across reboots. cron has worked for me for the past fifteen years or so.

If need a command to be executed once every day, and then be executed once even if the system goes down, you can use anacron.

share|improve this answer
    
I don't think cron is really good for this unless I use it as jj33 stated because I don't want to run something at regular intervals. For example, when I schedule even A I will want event A to run one month from now, but not every month. –  Kyle Brandt May 27 '09 at 13:55
add comment

When you schedule a job with at, even if a reboot is done (they are stored in /var/spool/cron/atjobs), the job is still planned.

Cordialy,

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.