Linux: Automatically shutdown your router on system shutdown

If you have a router with storage media attached it's rather important that it be shut down gracefully when powering it off, else filesystem corruption is a possibility.

In my case i shut down everything at night by powering off my PC, then my UPC which supplies power to all other attached devices. I wanted to auto-shutdown the router on system shutdown instead of killing the power by shutting off the UPC and there is tons of advice on how to accomplish this using a systemd unit file, every bit of which either failed to work for me or didn't sound reasonable, and then i found a post on the Manjaro forum that solved the problem.


  • Gracefully shut down router on system shutdown, but not on reboot.


assumed key file name: router_id_ed25519
assumed user name: dingaling
assumed router IP/port:

In /etc/systemd/system create the systemd unit file:

$ sudo nano shutdown-router.service

In shutdown-router.service adjust the following and paste it in the file:

Description=Shutdown router on system shutdown
# to test, comment out below and run: $ sudo systemctl start shutdown-router.service

ExecStart=/usr/bin/ssh -i /home/dingaling/.ssh/router_id_ed25519 poweroff


After saving the file, finish up with the following:

$ sudo systemctl enable shutdown-router.service
$ sudo systemctl daemon-reload

Leave a Reply

Your email address will not be published. Required fields are marked *