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".
Michael from wrote on Mar 5th, 2020:
You made my day! Thank you!
AWS Android Ansible Apache Apple Atlassian BSD Backup Bash Bluecoat CMS Chef Cloud Coding Consul Containers CouchDB DB DNS Database Databases Docker ELK Elasticsearch Filebeat FreeBSD Galera Git GlusterFS Grafana Graphics HAProxy HTML Hacks Hardware Icinga Influx Internet Java KVM Kibana Kodi Kubernetes LVM LXC Linux Logstash Mac Macintosh Mail MariaDB Minio MongoDB Monitoring Multimedia MySQL NFS Nagios Network Nginx OSSEC OTRS Office OpenSearch PGSQL PHP Perl Personal PostgreSQL Postgres PowerDNS Proxmox Proxy Python Rancher Rant Redis Roundcube SSL Samba Seafile Security Shell SmartOS Solaris Surveillance Systemd TLS Tomcat Ubuntu Unix VMWare VMware Varnish Virtualization Windows Wireless Wordpress Wyse ZFS Zoneminder