Testing OctoPrint activity from the command line on the Pi

Hi Folks,

I have a bash script which runs on the Pi and creates an image of my Octoprint SD Card on my NAS (amongst other things) which I'm intending to run with cron.

Before I do so, is there a method of testing if OctoPrint is "idle" and just serving the web page from the command line? I want to make my script wait until whatever is happening has finished before it stops the OctoPrint service and makes the image.


Andy B

not quite sure if there is any "easy" command line option build in
but you could use this command line client

Or just curl, possibly combined with jq:

curl "http://localhost:5000/api/printer?apikey=...&exclude=temperature,sd" 2> /dev/null | jq -c -r '.state.flags.ready' 2> /dev/null || echo "true"

This will output true if the printer is idle or disconnected and false otherwise.


Thank you for the quick responses guys, foosels solution will do nicely + jq is a new toy to play with! - need to go do some reading...

Andy B.

1 Like