I managed to find out how to suspend/hibernate the system from the command line by reading How can I suspend/hibernate from command line?.
However, I would like to know how to use the command line to suspend/hibernate at a given time, in absolute (example, 11PM) or relative (example, in 30 minutes) terms.
I already know how to do this with shutdown, but I'm note sure if the command is similar.
You can use the
at
command to schedule any action, including running the commands detailed in that question.For example, if you want to hibernate in 30 minutes:
echo 'pmi action hibernate' | at now + 30 min
Or if you want to suspend at 11:00 pm:
echo 'pmi action suspend' | at 11pm
If you need to run a command as
root
, runat
withsudo
rather than the command itself withsudo
(sincesudo
should only be run interactively, unless you've configured it not to ask for your password). For example, the equivalents of the above commands usingpm-hibernate
andpm-suspend
are:echo pm-hibernate | sudo at now + 30 min
echo pm-suspend | sudo at 11pm
For relative specification (e.g. "after 30 minutes") you can simply use
sleep
command to make suspending/hibernating command wait.Examples:
Wait 30 minutes, then suspend:
Wait 1 hour, then hibernate:
For specific times repeated - like shutting down computers are a specific time each day. use cron.
add the following:
If you want to customize it.
For a one time job us the at command
For example, if you want to hibernate in 30 minutes:
Or if you want to suspend at 11:00 pm: