Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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!

share|improve this question
up vote 3 down vote accepted

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
share|improve this answer

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...

share|improve this answer
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
share|improve this answer

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.

share|improve this answer
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 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.