Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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
add comment

2 Answers

up vote 5 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
add comment

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: http://michaelchrisco.com/wiki/index.php?title=Set_up_VLC_as_a_cron_job

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.