views:

46

answers:

3

I m trying to run a cron which involves opening a graphical program and thus needs a DISPLAY set. I have tried the following:

*      *      *       *      *      DISPLAY=:0.0 /opt/firefox/firefox -print ..

It does not work and even if I try it on my console the above command does not work. It just sits there doing nothing. Now, the only way it works is the following:

$ echo $DISPLAY
localhost:10.0
$ crontab -l
*      *      *       *      *      DISPLAY=:10.0 /opt/firefox/firefox -print ..

and this works if I stay logged into the machine and wait for the cron to run.

Is there a viable way to make this work? the only way I can thin of is to always stay logged into the machine (which I want to avoid).

+2  A: 

I don't think there is any simple setting to make this just work.

However, Xvfb (X Virtual Framebuffer) should be able to give you a dummy X display that should satisfy your need:

http://www.xfree86.org/4.0.1/Xvfb.1.html

Nate C-K
It seems like the right thing to do and I did read about Xvfsb. Its a little painful to get this running in the first place, so I just used a VncServer instead.
ankimal
A: 

I'm not sure if you can do this. But if you can do this, have you then checked if the X server running when you execute this command?

Kristinn Örn Sigurðsson
A: 

I think Nate C-K has the right idea, here is a guide on using Xvfb and a headless Firefox. Adrian Holovaty's blog also has a discussion on a similar need (the comments are useful).

If you just need to emulate a browser, there is always HTMLUnit and twill.

John Paulett