Search code examples
linuxarchlinuxkde-plasma

How to make a linux pc go to sleep after a period of time?


I'm running an Arch Linux KDE PC, and I like to listen to calming music before sleeping.

What command/script that I can run on my PC to make the device go to sleep (Or shutdown) after a period of time?

Example: Shutdown in 1.5h OR Sleep in 1.5h


Solution

  • To shutdown, use the relative format (+m) and schedule a shutdown in a defined number of minutes from the time you run the command. The command syntax is:

    sudo shutdown +m
    

    For example, to shut down the system in 90 minutes, run:

    sudo shutdown +90
    

    To suspend the system after 90 minutes, run:

    sleep 90m && systemctl suspend
    

    Similar workaround for powering off the system after 90 minutes is to run:

    sleep 90m && systemctl poweroff