How to start a GUI application from cron?





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ margin-bottom:0;
}







16















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 http://domain.com/iqms/packetloss/iqmspacket2.html









share|improve this question




















  • 1





    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


















16















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 http://domain.com/iqms/packetloss/iqmspacket2.html









share|improve this question




















  • 1





    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














16












16








16


4






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 http://domain.com/iqms/packetloss/iqmspacket2.html









share|improve this question
















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 http://domain.com/iqms/packetloss/iqmspacket2.html






firefox java cron






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 14 '15 at 14:46









Jacob Vlijm

66.7k9137234




66.7k9137234










asked Aug 21 '14 at 9:30









fadabi Nawifadabi Nawi

1411110




1411110








  • 1





    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














  • 1





    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








1




1





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





You can also use Selenium with python, which is easier for scripts.

– ESala
Nov 24 '15 at 13:17










2 Answers
2






active

oldest

votes


















21














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 x.com/iqms/packetloss/iqmspacket2.html"

    – fadabi Nawi
    Aug 22 '14 at 0:35








  • 1





    @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



















6














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 x.com/iqms/packetloss/iqmspacket2.html"; 


tq






share|improve this answer
























  • This helped, thanks a lot! Just a note: full path to Firefox is mandatory, I didn't realise that and it didn't work

    – aexl
    Jul 27 '18 at 7:28












Your Answer








StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "89"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f514167%2fhow-to-start-a-gui-application-from-cron%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























2 Answers
2






active

oldest

votes








2 Answers
2






active

oldest

votes









active

oldest

votes






active

oldest

votes









21














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 x.com/iqms/packetloss/iqmspacket2.html"

    – fadabi Nawi
    Aug 22 '14 at 0:35








  • 1





    @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
















21














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 x.com/iqms/packetloss/iqmspacket2.html"

    – fadabi Nawi
    Aug 22 '14 at 0:35








  • 1





    @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














21












21








21







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













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












share|improve this answer



share|improve this answer










answered Aug 21 '14 at 9:54









OliOli

225k90567768




225k90567768













  • 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 x.com/iqms/packetloss/iqmspacket2.html"

    – fadabi Nawi
    Aug 22 '14 at 0:35








  • 1





    @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



















  • 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 x.com/iqms/packetloss/iqmspacket2.html"

    – fadabi Nawi
    Aug 22 '14 at 0:35








  • 1





    @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

















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 x.com/iqms/packetloss/iqmspacket2.html"

– fadabi Nawi
Aug 22 '14 at 0:35







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 x.com/iqms/packetloss/iqmspacket2.html"

– fadabi Nawi
Aug 22 '14 at 0:35






1




1





@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





@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













6














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 x.com/iqms/packetloss/iqmspacket2.html"; 


tq






share|improve this answer
























  • This helped, thanks a lot! Just a note: full path to Firefox is mandatory, I didn't realise that and it didn't work

    – aexl
    Jul 27 '18 at 7:28
















6














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 x.com/iqms/packetloss/iqmspacket2.html"; 


tq






share|improve this answer
























  • This helped, thanks a lot! Just a note: full path to Firefox is mandatory, I didn't realise that and it didn't work

    – aexl
    Jul 27 '18 at 7:28














6












6








6







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 x.com/iqms/packetloss/iqmspacket2.html"; 


tq






share|improve this answer













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 x.com/iqms/packetloss/iqmspacket2.html"; 


tq







share|improve this answer












share|improve this answer



share|improve this answer










answered Aug 22 '14 at 0:44









fadabi Nawifadabi Nawi

1411110




1411110













  • This helped, thanks a lot! Just a note: full path to Firefox is mandatory, I didn't realise that and it didn't work

    – aexl
    Jul 27 '18 at 7:28



















  • This helped, thanks a lot! Just a note: full path to Firefox is mandatory, I didn't realise that and it didn't work

    – aexl
    Jul 27 '18 at 7:28

















This helped, thanks a lot! Just a note: full path to Firefox is mandatory, I didn't realise that and it didn't work

– aexl
Jul 27 '18 at 7:28





This helped, thanks a lot! Just a note: full path to Firefox is mandatory, I didn't realise that and it didn't work

– aexl
Jul 27 '18 at 7:28


















draft saved

draft discarded




















































Thanks for contributing an answer to Ask Ubuntu!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f514167%2fhow-to-start-a-gui-application-from-cron%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

mysqli_query(): Empty query in /home/lucindabrummitt/public_html/blog/wp-includes/wp-db.php on line 1924

How to change which sound is reproduced for terminal bell?

Can I use Tabulator js library in my java Spring + Thymeleaf project?