7

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!

2 Answers 2

6

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).

1
  • 1
    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! Aug 22, 2010 at 21:46
2

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

You must log in to answer this question.

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