Play a multimedia file in VLC as cron job

Written by - 1 comments

Published on - Listed in Linux


At work we have a Raspberry Pi 2+ connected to a monitoring screen (a Panasonic TV) to display the current status of Icinga2 monitoring and some additional visual monitoring (Nagvis) drawings.

I wanted to troll my colleagues by playing a regular video/sound from a scene of the movie Dante's peak (It's coffee time!). I was able to play the video without problems from the command line using "cvlc", however when the command was launched as a cron job, nothing happened.

This was due to the fact, that inside cron's environment, there is no display ($DISPLAY) configured. In order to do that, the cron command needs to use the local DISPLAY port:

00 09 * * 1-5 DISPLAY=127.0.0.1:0 /usr/bin/cvlc /home/pi/Downloads/COFFEE-TIME.webm; killall vlc

Working :-)

Update January 22nd 2019:
You may want to read the follow-up article "How to play an audio file on the command line or as a cron job in Linux".


Add a comment

Show form to leave a comment

Comments (newest first)

Michael from wrote on Mar 5th, 2020:

You made my day! Thank you!