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