2

I want to schedule a job using at command, but my laptop may have gone to sleep by that time. So the question is will that command will be executed?

If yes, how? I mean will my computer will wake and than the command will run or something else?
If not, why not?

2

"Sleep" is defined as ultra-low power usage: All subsystems get turned off and consume extremely little power but can be woken up quite quickly by an external event: lid open, power button, key press, WOL packet, BIOS.

So no, your command will not be running in "sleep" mode, but can run in low-power mode: in that mode, your disk turns off if not needed any more and the same goes for the screen, keyboard, ... but WiFi, LAN, memory, CPU, ... just keep churning away.

Alternatively, you can:

  1. Send WOL packets by one server that never sleeps and will "wake up" (even from hibernation or completely turned off) other machines that are allowed to sleep. (like the nightwatchmen that will wake up the full Royal Guard)
  2. If your BIOS supports this feature: Have the BIOS wake up your machine at a specific point in time. (another example of an external wakeup)

;-)

  • The BIOS ought to be able to schedule a time to wake at, that's easier than an external WOL packet. But I'm pretty sure at doesn't do so. – derobert Jan 22 '16 at 17:45
  • @derobert: True! (But I've only ever seen this on server BIOSes, not on clients: e.g. my laptop doesn't support this. So I'll add it anyway. Please tell me if you were thinking of servers only. – Fabby Jan 22 '16 at 18:39
  • I've seen it in desktop BIOSes as well, and Intel has something called Intel Smart Connect which does this in a lot of their current chipsets, unfortunately no Linux driver for it. – derobert Jan 22 '16 at 19:08
1

I don't think you can do that with at, but you can use rtcwake instead.

See also https://www.howtogeek.com/121241/how-to-make-your-linux-pc-wake-from-sleep-automatically/, in particular:

Use the && operator to run a specific command after rtcwake wakes your system from sleep. For example, the following command suspends your computer to RAM, wakes it two minutes later, and then launches Firefox:

rtcwake -m mem -s 120 && firefox

and

For example, to have your computer wake up at 6:30am tomorrow but not suspend immediately (assuming your hardware clock is set to local time), run the following command:

sudo rtcwake -m no -l -t $(date +%s -d ‘tomorrow 06:30’)

But note that unlike using at, you have to worry about whether it is midnight already: you obviously need tomorrow 06:30 before midnight and just 06:30 after midnight. This answer has a solution to that.

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.