Nightly/weekly/monthly auto reboot plugin

Would it be possible to develop a plugin for octoprint that is smart enough to do a scheduled recurring full system reboot at a scheduled interval, ie daily, weekly, or monthly, but smart enough to not initiate the reboot during a print event, ie connecting, loading, preheat, homing, bed leveling, printing, time lapse or cool down events? I’m not a coder by far, but I don’t feel as though this would be that difficult of a plugin to develop? I know it has to be time aware and current status aware with the ability to execute a system reboot command when the conditions are right. Can somebody with a deep knowledge of Octoprint’s inner workings tell me if I’m out of my mind or is this a plausible possibility. I do feel that octoprint and the Debian underlying OS is rock solid reliable on the raspberry pi 3b+, but I also believe it’s good house keeping to reboot the whole system from time to time. I do this manually about once a week.

1 Like

That is a plausible possibility.

I leave almost all the systems in my local area network running all the time with no ill effects. It is not unusual to have uptimes measured in months on some of the Linux-based systems. There are, however, some Windows systems that reboot (or get rebooted) regularly.

Most circumstances you would be correct sir, but I tend to run bleeding edge marlin firmware and bleeding edge octoprint software. This has been a great and fun hobby. With running this type of software, at least for me, it would be of benefit. I also feel that a great deal of other people that have IT experience would also feel this way. I tend to run DD-WRT on my own routers and schedule them to reboot once a week through a chron job.

Not a plugin but a cron job consisting of something like this would work for most cases:

(curl -H 'X-Api-Key: API_KEY_HERE' -X GET 'http://OCTOPRINT_HOST_HERE/api/job' 2> /dev/null | jq .state | grep -iv '(printing|pausing|paused|cancelling)') && shutdown -r now
1 Like

Very nice but probably need a sudo apt-get install jq to get this command to work.

In my testing, it appears I don't need the API key. Can you tell us when it is needed and when it isn't?

Did you enable autologinlocal? If you did, then a key may not be required in that case maybe.