You are not logged in.
Hi, I wrote a script that updates firefox-nightly, inside the script I am having problems restarting firefox-nightly after the update. It does restart properly when run from inside a X session, but not from dcron. Any advice?
restart function:
restartff() {
kill $(pgrep firefox) && firefox-nightly --display=:0
}
crontab:
00 03 * * * bash /usr/local/bin/firefox-nightly-update
Last edited by sekereg3 (2010-12-25 16:53:51)
Offline
Doesn't cron run as root? Running GUI apps as root is not a good thing + you need to properly set up your system to do that.
Offline
@karol - deps. If the op put that line in his user's crontab it'll run as his user. If he has it in root's crontab or in the /etc/cron.d folders then you're right it'll run as root. In that scenario, start the script with a su user -c like this:
00 03 * * * su USERNAME -c /usr/local/bin/firefox-nightly-update
CPU-optimized Linux-ck packages @ Repo-ck • AUR packages • Zsh and other configs
Offline
yes, of course I have it in my users crontab.
Offline
yes, of course I have it in my users crontab.
...I assumed that you did. Just wanted to follow-up on k's post.
CPU-optimized Linux-ck packages @ Repo-ck • AUR packages • Zsh and other configs
Offline
yes, of course I have it in my users crontab.
Ooops, sorry then.
Firefox is an X application so I think it needs an X display to connect to.
You can give 'nohup' a shot:
restartff() { kill $(pgrep firefox) && nohup firefox-nightly --display=:0 & }
Last edited by karol (2010-12-25 16:01:19)
Offline
you can also add the line
DISPLAY=:0.0
or whatever directly to your crontab before your jobs. Then you only have to specify the display once for any X apps you run via cron, assuming you want to have them all run on the same display.
EDIT: No, I am wrong about exporting. I can't get it to work as advertised. But I can put something like this in my crontab and run X apps via cron:
* * * * * DISPLAY=:0.0 /usr/bin/my-gui-cron-job
However, it looks like you have to specify the display with every job in the list for every X app you want to run via cron. I have tried exporting it both at the beginning of the crontab file and on the job line itself, but I am unable to specify the display just once for multiple gui cron jobs. Still, the above is handy for a graphical app which has no command-line switch to specify a display and which is to be run by cron.
Anyway, I know the OP's problem is solved, but I want to make sure no one else bangs their head against the wall due to my misinformation.
Last edited by hellomynameisphil (2010-12-26 06:12:27)
Offline
you can also add the line
DISPLAY=:0.0
or whatever directly to your crontab before your jobs. Then you only have to specify the display once for any X apps you run via cron, assuming you want to have them all run on the same display.
I think it should be 'export DISPLAY=:0.0'.
Offline
Thanks for the help everyone, karol's suggestion works perfectly. hellomynameisphil: very nice suggestion for future scripts/ideas.
Offline