After getting XBMC Live installed on my Revo and getting my library setup, I couldn’t find a simple option to have XBMC watch my video folder and automatically update my library. In place of this missing functionality, I figured I would setup a simple timed job to automatically update my library for me every hour.
Before I get started, I should note that there is an option to automatically update the library when the box is booted up which may work for some people. You can find this under System > Video > Update Library on Startup. This option wouldn’t work for me though as I leave my box on 24/7 or at most just put it in a standby state.
See below for the details on how to setup a timed job (cron) to update your video or music library. This consists of installing the xbmc-send application and setting up a cron job (and enabling the EventServer).
Access the shell of your XBMC installation (either via SSH/putty or directly from the keyboard/Ctrl+Alt+F2) then run the following commands:
Update the Aptitude local repository:
sudo apt-get update
Enter the password for the super user if prompted (the default is ‘xbmc’).
Install the xbmc-send client:
sudo aptitude install xbmc-eventclients-xbmc-send
Enter the password for the super user if prompted (the default is ‘xbmc’).
Press Y to continue when prompted.
(Optional) Test out a command:
xbmc-send -a "Notification(Testing,XBMC Command Success.)"
You should see a quick notification box popup on your XBMC installation as soon as you press enter on the above command.
(Optional) Test if Cron is installed:
Oddly enough, cron was not installed by default on my XBMC-Live 9.11 (repack) installation so I had to manually install it first. To test if you have cron installed, try running the following command:
crontab -l
If you get an error that says something like “crontab: command not found” then you need to first install cron using the optional step below. If you get a listing of your cron entries or a message that says “no crontab for [username]” then you can skip the optional next step of installing cron.
(Optional) Install Cron:
sudo aptitude install cron
If prompted, enter the root user password and hit Y if prompted to continue.
Setup the Timed Job (Cron):
Edit the crontab entry for the root user, using the nano editor:
sudo env EDITOR=nano crontab -e
You should now see a blank, command prompt version of something similar to Wordpad. If your crontab was empty, all you will see is “# m h dom mon dow command”. Press down to start a new line and copy the following in:
0 * * * * /usr/bin/xbmc-send -a "UpdateLibrary(video)" >> /dev/null 2>&1
Press Ctrl+O to save. Press [enter] to confirm saving to the default filename. Press Ctrl+X to exit the nano editor. Congratulations, your cronjob should now be setup to run every hour!
Other Thoughts:
Here are some other ways to setup your cron job to run. Use these in place of the default line that you pasted into the editor in the last step above:
At midnight every day:
* 0 * * * /usr/bin/xbmc-send -a "UpdateLibrary(video)" >> /dev/null 2>&1
Every 3 hours:
* */3 * * * /usr/bin/xbmc-send -a "UpdateLibrary(video)" >> /dev/null 2>&1
At 4:30pm (16:30):
30 16 * * * /usr/bin/xbmc-send -a "UpdateLibrary(video)" >> /dev/null 2>&1
If the test command doesn’t work, you may need to enable the Event Server (XBMC Wiki Article). In 9.11 Camelot, this is under System > Network > Services > Allow programs on this system to control XBMC (and by default should be on).
You can also use the list of functions from the XBMC wiki to schedule other cronjobs or create your own shell scripts for more fun automation on the XBMC platform.
Leave a Reply