18

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

Comments
  • 2
    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
    I guess that makes sense to some degree, you wouldn't want to connect to a box and then have it unwittingly shutdown because someone else ran a shutdown command an hour ago. But still, that's kinda annoying
  • 2
    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
  • 3
    @filthyranter user problem ¯\_(ツ)_/¯
  • 0
    @bahua In a screen terminal, maybe... Because I want to close the SSH session anyways.
Your Job Suck?
Get a Better Job
Add Comment