Search code examples
cronxbmc

Cron jobs on RaspBMC


I'm trying to make the following script run at 17:00 everyday on Raspbmc using crontab. Cronjob scheduler is activated and running, but the script does not get executed. The crontab I used is:

0 17 * * * python /home/pi/.kodi/userdata/test.py

and my script is:

import xbmc
xbmc.executebuiltin("PlayMedia(/home/pi/.kodi/userdata/playlists/music/test.m3u)")
xbmc.executebuiltin("PlayerControl(Random)")

I could use a service called "XBMC Alarm clock", it works, but I need the songs to be shuffled!

What am I doing wrong?


Solution

  • I figured it out, I had to execute the following through SSH:

    1).sudo apt-get install xbmc-eventclients-xbmc-send

    2).xbmc-send --action='RunScript("/home/pi/.kodi/userdata/test.py")' (to test if the script works through SSH)

    or

    3).0 17 * * * xbmc-send --action='RunScript("/home/pi/.kodi/userdata/test.py")' (to set the crontab)

    Of course you need to make the script executable (755 permissions) and set the python env, as previously mentioned.

    Thanks for the the replies!