Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm developing a display system for a paint shop.
I've set up a computer with Ubuntu to run the video and display it on a TV, running a PHP script that should update the video every hour via the internet.

The script is set to run via cron, executed once every hour (@hourly). Almost the entire script runs perfectly, but the last line where it executes VLC Media Player to display the video fails silently. If the script is run via command line (php /path/to/cron.php), VLC Media Player starts perfectly. But when it is run in cron, it does not.

The thought I get is, that jobs running via cron simply doesn't have the ability to run applications with a visible GUI, but I really hope that is not the answer.

Please help me crack this one!

share|improve this question
up vote 6 down vote accepted

To display something on an X server the X client (like vlc) requires an environment variable DISPLAY to be set which defines network address of the X server. In almost all cases (one local X server) it should be assigned to :0.

You can set that variable from your script or just run bash -c "DISPLAY=:0 vlc $vlcopts" instead (of course replacing $vlcopts).

share|improve this answer
This is fantastic! I never thought of the DISPLAY variable. Well, you may think that this wasn't a hard one, but you sure solved my problem. Thanks a lot! – Sune Rasmussen Aug 22 '10 at 21:46

You can also use:

@hourly screen -d -m vlc-wrapper /path/to/file/foo.flv --novideo --volume 700 --repeat --rc-fake-tty

To make vlc work. There is a detailed process here:

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .