19

I want to schedule jobs with at, but I'm not sure what happens if the computer is suspended at the specified time: Will the command be executed as soon as the computer wakes up again (like with anacron) or will it not be executed at all (like with cron)?

If you specify a job to absolutely run at a specific time and date in the past, the job will run as soon as possible.

That's what the manpage says about that, however it doesn't quite match my case: I don't want to specify a job to run in the past, I want to run it in the future and ask how at will treat it if the computer is sleeping then.

This is not a duplicate of Run at command when computer is sleeping because this question asks whether at will wake up the computer to execute the command, neither is it a duplicate of How to prevent atd from running past jobs? because this is about how to prevent at from executing those “old” jobs (with a very good answer though!).

20

at executes any command that should have been executed before when you wake up the computer, but may take a few minutes to do that. It doesn't even matter whether you gave it a specific date, as you can test easily:

$ sudo date -s "2017-12-15 23:57:00"
$ at 23:59 17-12-15 <<<'echo executed >at_test'
job 1 at Fri Dec 15 23:59:00 2017
# suspend, wake after four minutes
$ date
Sat Dec 16 00:01:17 CET 2017
$  cat <at_test || atq
bash: /home/dessert/at_test: No such file or directory
1       Fri Dec 15 23:59:00 2017 a dessert
# wait a few minutes
$  cat <at_test || atq
executed

So a job you add using at 20:00 today can very well be executed suddenly three days later when you power on your computer again. If you want to prevent this you can check for the time in the job itself like proposed here: How to prevent atd from running past jobs?

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.