2

I have an ubuntu server with XBMC installed and the server connected to a TV via an HDMI cable. To launch XBMC I am running the command:

sudo init xbmc

By using ssh to remote to the server and then running the command that way. This seems to work fine at the time and I will be able to watch a film or a TV show. After a few hours XBMC seems to stop running whether it is playing something or not, which means that every time I wish to watch something I have to ssh to the server and run that command.

My ideal solution would be to only have to run that command once so that I could turn the TV off and go away for an indefinite period but when I come back I can use XBMC without having to log in and run that command.

I reckon I must be starting XBMC incorrectly or perhaps there is something in the settings that I have not set properly, can anybody help?

  • is this a dedicated server for XBMC? – dawud Apr 15 '14 at 12:32
  • No, it is used as a testing server for other things such as websites and small programs. Just a box I use to learn things with really. – Aesir Apr 15 '14 at 13:07
1

There are several ways to do this, depending on how is this server used (i.e., if it is a dedicated HTPC or not), an upstart script might be the best fit for you. This one from the same XBMC wiki article linked before:

# xbmc-upstart
# starts XBMC on startup by using xinit.
# by default runs as xbmc, to change edit below.
env USER=xbmc

description     "XBMC-barebones-upstart-script"
author          "Matt Filetto"

start on (filesystem and stopped udevtrigger)
stop on runlevel [016]

# tell upstart to respawn the process if abnormal exit
respawn

script
  exec su -c "xinit /usr/bin/xbmc --standalone -- -nocursor :0" $USER
end script

You can also disable the service from autostarting, so you're still able to log in remotely via ssh and run XBMC.

  • This did seem like a promising solution, but when I went to create the file it already appeared to exist with the same content, so I am going to assume that it does not work as a solution, unless you are aware of anything else I had to do for this to work? – Aesir Apr 17 '14 at 17:59
  • Do you use it to start XBMC? Because it should respawn itself on exit. – dawud Apr 17 '14 at 19:41
  • To start xbmc I just type the command: sudo xinit xbmc. How do I start xmbc using this script instead? – Aesir Apr 19 '14 at 21:26
  • 1
    As you normally would with any other service that uses upstart – dawud Apr 19 '14 at 21:30
  • Ah ok thanks, I wasn't aware of that, I'll try it out, cheers. – Aesir Apr 19 '14 at 21:33
0

You can run the program in the background by appending an ampersand to the command.

sudo init xbmc --standalone -- -nocursor :0 &

This will ensure xbmc is not killed by a timeout without having to use screen.

0

You can also use a workaround: Let a cron-job check every few minutes if XMBC is still running and start it again if it is not. The corresponding bash could look like this:

#!/bin/bash

if [ `ps u | grep xmbc | wc -l` != "2" ]; then
    screen -dm init xmbc
fi

Maybe you have to adjust the line count (the "2" part) if xmbc spawns child processes. Depending on your setup, it could also work without screen.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.