Best Way to Automate Shutdown After Print on Pi 5?

Hey folks,

I recently upgraded to a Raspberry Pi 5 tool and everything’s running buttery smooth with OctoPrint. One thing I’d love to automate is a safe shutdown of the Pi once a print finishes.

I’ve seen some people use PSU Control with relays or scripts, but I’m wondering—what’s the most reliable and Pi 5–friendly approach for this in 2024?

Would love to hear what’s working for you!

— Jhonn Mick

Hello @jhonnmick !

And what has this to do with Networking?

grafik

FWIW, I leave my Raspberry Pi turned on all the time. It doesn't use much power and having it available is useful. I do have my 3D printer on a smart plug and use an OctoPrint plugin to turn it off when I'm not printing.

2 Likes

A few of my plugins can do it along with powering off the printer via smart plugs or Tasmota relays. But if you just want to safely shutdown you could use the bundled event manager plugin and add the system command sudo shutdown now for the PrintDone event.

I have used 'sudo shutdown now', but I want to be clear of the different ways to shutdown (Pi3b+, 4b).
Makezine/com publishes a book "Getting Started with Raspberry Pi", where on page 22 they use: 'sudo halt'. However, their book "Linux for Makers", on page 91 they use 'sudo shutdown -h now'. I'm assuming they do the same but is one preferred over the other?

pretty sure halt (-h) will forcefully kill things, whereas sudo shutdown now doesn't, giving time for things to cleanly shutdown (ie plugins that react to shutdown events).

but, I'm no linux guru...

I use a TP-Link wifi smart power switch. That way I can turn it back on remotely.

But only after a regular shutdown of the Pi.