Ask Ubuntu is a question and answer site for Ubuntu users and developers. 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 need to run a Java applet from a Firefox. The problem is, I need to run this Firefox from a cron. If I run from the command line and its work fine, but when put the command in the cron it failed:

*/1 * * * * firefox
share|improve this question
You can use Selenium's java library if you need more functions than just opening it. – Övünç Metin Aug 21 '14 at 14:08
You can also use Selenium with python, which is easier for scripts. – ESala Nov 24 '15 at 13:17

Cron runs in an environment that knows nothing about the display manager ($DISPLAY isn't set). Your terminal window that you've been testing in has this set for it. If you tried it in a "real" terminal, or over SSH, you'd see it break.

If you've only got one X server running, just specifying the display might work:

* * * * *    DISPLAY=:0 firefox ...

You could probably put more effort into working out what display it's sitting under rather than assuming it's :0 but that will probably work most of the time.

If you just need to reload something a lot, look at Tab Auto Reload or similar Firefox plugins.

share|improve this answer
I found this answer but still does not start the firefox. After a few search, I found that i need to run as a valid user instead from root. * * * * * "DISPLAY=:0.0 /usr/bin/firefox -new-window"; – fadabi Nawi Aug 22 '14 at 0:35
@fadabiNawi An easier way of managing that would be to install the cron line into the correct user's crontab. Log in as who you want, and crontab -e – Oli Aug 22 '14 at 6:56
up vote 1 down vote accepted

I found this answer i am looking for addition to oli's :

After a few search, I found that i need to run as a valid user instead from root.

* * * * * su fadabi -c "DISPLAY=:0.0 /usr/bin/firefox -new-window"; 


share|improve this answer

Your Answer


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.