14

TIL shutting down a Linux machine with systemd with a delay will block new SSH sessions until the shutdown/restart happened.

Comments
  • 1
    Makes sense
  • 0
    Oh. I see thanks for info. I will try this.
  • 0
    @Kimmax No, I mean while the machine isn't even shutting down.

    If you do

    # shutdown -r +180

    and close the SSH session, you can't connect to that server. You can't remotely cancel a shutdown (or in this case reboot) of three hours.
  • 1
    Why would you do a delayed shutdown if you don't mean it? Makes sense to me that incoming SSH sessions would be blocked. If you screwed up, then just open the console.

    If you don't have console access, then take the lesson and be glad you didn't learn it during prod maintenance.
  • 0
    @bahua I am always confusing seconds with those minutes with that command, I wanted it to reboot in 3 minutes because of cron jobs still running which would be done by them, but then I typed 180 because I thought it was seconds...

    Anyways, I'm trying to make myself remember systemd's weirdness.
  • 0
    @filthyranter

    You could always just do it after a sleep command.

    sleep 180 && init 0
  • 1
    @filthyranter user problem ¯\_(ツ)_/¯
  • 0
    @bahua In a screen terminal, maybe... Because I want to close the SSH session anyways.
Add Comment