Skip to main content
3 of 3
Added details about my setup

How to shutdown pc if no user is logged in?

I am sorry if I have missed any existing answers or solutions - my searching did not bring up any viable solutions yet.

The issue:

My pc contains Windows and Linux, with Linux being the primary OS. Windows is used occasionally and has got the tendency of doing a reboot upon shutdown, to install some updates and then really shutdown. However, as Linux is the primary boot target, this reboot-then-shutdown will boot into Linux, where it will sit at the logon indefinitely. I want it to time out after 5 or 10 minutes of no login and shutdown.

The solutions / attempts:

I have come across setting a timeout in /etc/systemd/login.conf

IdleAction=poweroff IdleActionSec=10min 

However, this kills my session after 10 minutes even if I am actively typing.

I have also found this post, about regularly checking if a user is logged in and then shutting down. Unfortunately, I have never written a bash script or set up systemd timers, which is why I am at a bit of a loss with this answer.

My setup: I am running Arch Linux, with the login being the console-based tty-login.

Thank you for any hints or recommendations.