Auto play video with cron

Hello!

So I’ve been searching for an answer for some time, but didn’t manage to find anything.

I need to set up a script to run a video at certain time, using Cron my script looks like this in crontab:

40 10 * * * xbmc-send -a PlayMedia(/home/osmc/movies/testvid.mp4)

But with it, the video doesn’t start at 10:40 (it’s time in osmc as well)

What am I doing wrong?

Thank you in advance

Try the full path /usr/bin/xbmc-send.

Also remember that crontab uses 24 hour times, so your current line is activated at 10:40 AM.

And you probably should quote the filename.

The file is called testvid.mp4, as it’s written in an example code.

I tried the full path but it doesn’t work too.

Is there a possibility that I run crontab wrong? I have installed it on osmc, the program is installed when viewed from My OSMC. Writing down the script in crontab -e, saving in the same place. Is there anything else I need to do with it for it to work in osmc?

Currently the script looks like this:

06 11 * * * /usr/bin/xbmc-send -a PlayMedia (/home/osmc/movies/testvid.mp4)

(I’m changing time to test it out)

Does /usr/bin/xbmc-send -a PlayMedia (/home/osmc/movies/testvid.mp4) work from command line?
you can check logs via sudo journalctl -f to see whats happening

Tried running it from command line, says syntax error near unexpected token `(’

Upon running Cron with journalctl open, it says
(CRON) info (No MTA installed, discarding output)
And then it closes

So first get it working from command line before moving to crontab.
Short hint " always is a good trick if you have spaces

I got it working! The final code was
47 11 * * * xbmc-send -a “PlayMedia (/home/osmc/Movies/testvid.mp4)”

Lesson for the future for me, that it’s very sensitive to the path. It was refusing to play video until I made M capital.

Thank you for help! Couldn’t have done it without you!