3

Anyway to set a timer to suspend the system say in 120 minutes similar to doing:

$ shutdown 120

But for suspension. I want to encode some stuff in handbrake and I want my pc to automatically go to sleep after so much time.

2
  • 3
    sleep 120m && systemctl suspend ? Unless you want to use systemd-inhibit (as suggested here)... Commented Jun 26, 2017 at 23:04
  • If you additionally want to lock your PC first, ISTR having to use e.g. sudo sh -c 'sleep 120m && systemctl suspend'. The screen lock seems to revoke your console permissions.
    – sourcejedi
    Commented Jul 11, 2017 at 19:35

1 Answer 1

4

You can use at to schedule any action.

Firstly, you have to install at:

sudo pacman -S at
# or
sudo apt install at

Then, start service at:

systemctl start atd

And now you can do something like that:

echo 'pmi action suspend' | at 4pm

Or like that:

echo pm-suspend | sudo at now + 10 min

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .