Delayed shutdown after finished print, possible?!



I have an Anycubic i3 Mega. When i print "offline" via SD-Card and the print is finished, the PSU Fan and Mainboard Fan are cooling down the printer for about 5 minutes after the print. Is it possible to add a delay in the Automatic Shutdown Plugin? Where you have multiple options, e.g. "Shutdown printer 5 minutes after print is finished" ; "Shutdown printer 2 minutes after print is finished" and so on.

It would be very nice if someone can help me! :slight_smile:

Thanks and best regards



I moved this over to the Plugins area since you're asking for help with the Automatic Shutdown plugin itself.


you can do this yourself rather easily ...

the "shutdown" is usually done trough G-CODE (mostly disabling the printer with M18 or M84 or both) ... so all you want to do is find where you are injecting this M18 or M84 (end of print in octoprint or end of script in your slicer or ...) and remove it :slight_smile: ..

then you at the scripts part of the gcode edit "ending scripts" and add something like

M400 ; wait for queue to be empty
G4 S300 ; wait 300seconds 
M84 ; disable steppers


I do this with PSU Control plugin, that turns off the printer power supply after x minutes.


I use a "sonoff POW" for remotely turn on/off my Printer.
Under Settings / Octoprint / Server I added a shellscript e.g. /home/pi/scripts/
So each time the system is shutdown (via plugin or web-menu) this script is executed.
The script looks like this:

echo "Shutdown System and power of after a short delay"
echo "...Sonoff call..."
curl ";Power%20Off"
echo "...shutdown..."
sudo shutdown -h now

You can replace the sonoff-call with something like sleep 5m




Ok. So i created an script and "imported" it into Octoprint. Sadly it´s not working, and i don´t have any idea whats the problem. Can you have a look at these please?

I would be very happy if you can help me to fix this problem.

So i would like to create a script, that shuts down the printer (and maybe the Raspberry too) after a finished print, then wait (for example) 5 minutes and then shut it down.


Could you execute the script directly?
Maybe a permission problem: chmod 777
Also try to add sudo in the web UI like the other calls.


̶e̶̶d̶̶i̶̶t̶̶:̶̶ ̶̶t̶̶h̶̶e̶̶ ̶̶e̶̶r̶̶r̶̶o̶̶r̶̶ ̶̶i̶̶n̶̶ ̶̶l̶̶i̶̶n̶̶e̶̶ ̶̶5̶̶ ̶̶i̶̶s̶̶ ̶̶a̶̶l̶̶r̶̶e̶̶a̶̶d̶̶y̶̶ ̶̶f̶̶i̶̶x̶̶e̶̶d̶̶!̶̶!̶

̶i̶̶ ̶̶g̶̶e̶̶t̶̶ ̶̶t̶̶h̶̶e̶̶s̶̶e̶̶ ̶̶e̶̶r̶̶r̶̶o̶̶r̶̶s̶̶ ̶̶w̶̶h̶̶e̶̶n̶̶ ̶̶i̶̶ ̶̶t̶̶r̶̶y̶̶ ̶̶t̶̶o̶̶ ̶̶r̶̶u̶̶n̶̶ ̶̶i̶̶t̶̶ ̶̶d̶̶i̶̶r̶̶e̶̶c̶̶t̶̶l̶̶y̶̶ ̶̶f̶̶r̶̶o̶̶m̶̶ ̶̶t̶̶h̶̶e̶̶ ̶̶p̶̶u̶̶t̶̶t̶̶y̶̶ ̶̶s̶̶e̶̶s̶̶s̶̶i̶̶o̶̶n̶̶,̶̶ ̶̶p̶̶l̶̶e̶̶a̶̶s̶̶e̶̶ ̶̶h̶̶a̶̶v̶̶e̶̶ ̶̶a̶̶ ̶̶l̶̶o̶̶o̶̶k̶̶:̶



When i start the script directly from the putty session via "./" it runs like it should. But from the octoprint web UI it´s not working. I also added "sudo" to the command. But what is the problem?

BTW: Is there an option to add an Marlin Command to a shell script? And if yes, how?


Give it the full path as run from OctoPrint.