Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I need to load a page once per hour and execute the javascript on that page. I currently load the page manually with Firefox, but I would like to automate this by running a cron job on the server, which is Ubuntu Server 8.04 LTS.

Some web searching suggests that the best thing would be to run firefox -remote openurl(...) and let gecko run the javascript, but this requires X11 which I don't know how to simulate on a server install.

So essentially I want an hourly job to run firefox in a simulated environment and discard the output. (I'm not wed to firefox... I'd happily take a wget-like command that executes javascript.)

share|improve this question
add comment

3 Answers 3

up vote 1 down vote accepted

You can run a graphical browser (e.g. Firefox) that's displaying in a virtual X server (Xvfb). See How can I run Firefox on Linux headlessly (i.e. without requiring libgtk-x11-2.0.so.0)?, and perhaps also How do I start Xvfb on startup on Debian?.

Elinks is a text mode browser with optional Javascript support. The version in Ubuntu 8.04 is compiled without the JS support, so you'd have to compile your own and link it with the Mozilla SpiderMonkey JavaScript library. These instructions in the manual may help.

share|improve this answer
add comment

Just to add this to the mix, we ended up using HTMLUnit instead of the above.

share|improve this answer
add comment

You could try http://www.phantomjs.org/ a headless WebKit browser.

share|improve this answer
    
Thanks for the pointer, Joby, but it looks like PhantomJS requires Xvfb anyway (ie, it's not really headless) so I'm probably just going to use Firefox (which I don't have to build myself). –  Fixee Apr 5 '11 at 0:31
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.