The at daemon is a great tool! However, if a job is scheduled for 8:00 am and the machine is off at that time, at will run the job whenever the machine is booted. What I would like to do is stop it from running the job if the time is past. I have searched the man pages, and online, but either there is not an answer or I could not find one. I am using Arch, but as far as I know at is very similar across distributions.

Any help is much appreciated!


When does a job become a past job? If you turn on the system at 7:59:50 and the at daemon starts at 8:00:01, should the job be executed? What if the daemon starts at 7:59:59 but takes two seconds to read all of its files?

You decide! Start your job with a time check, and abort if the time is past.

export execute_by_date=$(date +%s 'tomorrow 8:01')
at tomorrow 8:00
[ "$(date +%s)" -le "$execute_by_date" ] || exit

You could write an init-script that cancels all sheduled at-jobs on shutdown or reboot.

I am not sure about Arch-Linux - is there a /etc/sysconfig/at or something similar? Perhaps it is just a config-switch you have to flip over...

  • I think this is the best solution, flush the at queue at boot before at starts up. – bahamat Jul 25 '12 at 0:31
  • This is exactly what I expect would/should be possible! Unfortunately there is no /etc/sysconfig/ directory at all in Arch... And none of the files listed in the man pages are config files. – Elmer Jul 25 '12 at 2:34
  • @Elmer I just Googled a bit and read about arch linux. '/etc/rc.d/atd' seems to be the init-script for the at-daemon there. Have a look there if you can see it parsing some config-file. If you are not lucky there you have to go for your own init-script (e.g name it atclear and run it before atd). – Nils Jul 25 '12 at 19:21

My vote is for the cron daemon.

If you need to run it at specific times of the day, but not at the same time each day, I'd create a crontab with one entry per day range with an specific execution time:

Some examples taken from crontab(5):

# run five minutes after midnight, every day
5 0 * * *       command
# run at 2:15pm on the first of every month
15 14 1 * *     command
# run at 10 pm on weekdays
0 22 * * 1-5    command

What you want is the cron daemon. It does exactly what you want.

Feed you favourite search engine for cron daemon and you have a bunch of manuals and instructions. man cron and man crontab is also helpful.

  • Thanks for the help, but cron does not work for my problem. I need a script run at specific times of the day, but not at the same time each day. – Elmer Jul 24 '12 at 17:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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