Skip to content

This script is for scheduling server restarts on 3D printers running Octoprint on a raspberry pi. It utilizes the OctoPrint API so it will not restart if a print is running or the printer is disconnected.

Notifications You must be signed in to change notification settings

dorfman2/nightly_octopi_restart

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Nightly Server Restart Script

About

This script is for scheduling server restarts on 3D printers running OctoPrint on a raspberry pi. It utilizes the OctoPrint API so it will not restart if a print is running or the printer is disconnected. It does attempt to reconnect once.

Setup

  1. Clone the script to your pi
cd /home/pi/
git clone https://github.com/dorfman2/nightly_octopi_restart.git
  1. Navigate inside the folder
cd nightly_octopi_restart/
  1. Using an editor of your choice, fill in your API key and IP address into the config.py file.

  2. Make the script executable

chmod +x restart_print_check.py
  1. Create/Edit your root user crontab

  2. Type sudo crontab -e and press enter.

  3. If this is your first time editing crontab, select option '1.'

  4. Add this line to the end of the file. By default it runs at 2 am.

0 2 * * * /home/pi/nightly_octopi_restart/restart_print_check.py >> /home/pi/nightly_octopi_restart/restart_cron.log 2>&1
  1. Press CTRL S and then CTRL X.

Changing the time it runs at

More information about how to use cron can be found here.

I find this tool to be incredibly useful for helping to change

Troubleshooting

Testing that your script can be run by crontab.

  • Type into terminal env -i /bin/bash --noprofile --norc and press enter.
  • Then paste this and press enter.
/home/pi/nightly_octopi_restart/restart_print_check.py >> /home/pi/nightly_octopi_restart/restart_cron.log 2>&1
  • If the Pi restarts, your script has correct permissions and is in the correct location.
  • If not, check restart_cron.log.

About

This script is for scheduling server restarts on 3D printers running Octoprint on a raspberry pi. It utilizes the OctoPrint API so it will not restart if a print is running or the printer is disconnected.

Topics

Resources

Stars

Watchers

Forks

Languages