Script to reboot program on pi os if it failed to launch

March 16, 2024, 04:04

thecharlesshow

Hello everyone im making myself a personal signage display that uses chromium that sometimes throws up this error. I have everything automated using .bashrc (pi boots up, unclutter loads to hide the mouse) then the command chromium-browser “website.com” -kiosk -incognito. It works 7 out of 10 times. The other 3 times I get thrown the error pictured below. I was wondering if it was possible for me to make a fail safe that will detect that chrome didn’t successfully launch and commit a safe reboot to make a new attempt… thanks!

k9t33n

are you using a crontab to run the command on boot?

k9t33n

if so you can use | which runs the second command if the first one fails so in crontab you would put [command] | [command again] atleest that's how I remember it, it may be || or something similar so do a lot of testing

oops.se

Can you post the text as text not a picture as the picture is unreadable. And https://stackoverflow.com/questions/17938511/how-can-i-automatically-restart-chromium-if-it-crashes

thecharlesshow

I’m using .bashrc

k9t33n

ok and what do you put in there? like a command which opens chromium?

k9t33n

sorry I usually use crontab not .bashrc so it didn't know what it was really

thecharlesshow

Yes.

thecharlesshow

Chromium-browser “Google.com” -kiosk -incognito

thecharlesshow

As an example

thecharlesshow

Even if I used crontab bashrc would still have stuff to do anyways.

k9t33n

ok then you'd replace that with Chromium-browser “Google.com” -kiosk -incognito || Chromium-browser “Google.com” -kiosk -incognito which would run the command a second time if the first one fails

thecharlesshow

Or could I do the second command as reboot?

k9t33n

yes

k9t33n

you could put anything in that

thecharlesshow

Thank you!

thecharlesshow

Gonna try it now

thecharlesshow

I would legit tip you if this works.

k9t33n

no need