Auto restart XBMC on crash script
#1
I'd like to make a script I could run (as a cron job maybe) that auto-restarts XBMC if it dies (since unfortunately that seems to happen with my system). I'm thinking it could be something like this:
Code:
#!/bin/sh
if [ $(pidof xbmc.bin) ];
then
        echo "" #do nothing
else
        echo "XMBC Stopped, Re-starting"
        export set DISPLAY=:0
        /usr/bin/xbmc
fi
echo $PID
However, when I tested this via SSH it (of course) changed the display commands to my shell, so the mouse & keyboard stopped working on the TV (even though display did go correctly to the TV). Any ideas how to improve this? Or even do it correctly? Or what the correct crontab run line would look like?
Reply
#2
Why not just run XBMC in a loop that checks the return status? We have some special ones for shutdown, restart, hibernate, etc. They'll need checked too. The values should either be in the forums or changelog (maybe even the wiki). Unfortunately all of my usual ways to crash XBMC seem to be fixed so I can't test this and give you the exact command.
Reply
#3
Has anyone created a successful script or know how to run XBMC in a loop?
Reply
#4
WARNING: a very hard to stop script

while true; do xbmc ; echo restarted; done
Reply
#5
Check the return status...
Reply
#6
I started experimenting with using the command
Code:
pidof
and then just checking if the value returned was a number or an empty string, and if an empty string then restart it, but then I found the scripts in the tips and tricks thread that allow you to associate restarting (and killing) XBMC with buttons on the remote, and decided to go that route instead.

So making a looping script should be pretty much what I did above. I think my main problem was that I was trying to run it over SSH. If you set that script (or something like it) as a cron job it ought to work out all right
Reply
#7
Yeah, I have my record-button mapped in irexec, allowing me to start XBMC after killing it manually. I still dont have a way to restart X which I sometimes want, but I might fix that sometime now that I have a harmony remote with "unlimited" additional buttons in the menus.
Reply
#8
Hello everybody! This is my first message... I never installed XBMC (yet) but I work as a Linux admin here in Italy...

Linux has a simple way to start various programs on boot (restarting them automatically if they die): you can insert a line like this

Quote:xbmc:5:respawn:/root/xbmc.sh > /dev/null 2>&1

inside /etc/inittab file

where /root/xbmc.sh is executable and contains

Quote:#!/bin/bash
export DISPLAY="0:0"
exec xbmc

You should also verify that the line

Quote:id:5:initdefault:

is present inside /etc/inittab (this enables the start at boot time and automatic respawning of the X server).

Hope that helps...
Of course, "man inittab" is your friend... feel free to ask me if there is something I left out :-)
Reply

Logout Mark Read Team Forum Stats Members Help
Auto restart XBMC on crash script0