All new Registrations are manually reviewed and approved, so a short delay after registration may occur before your account becomes active.
Debian sh, bash, and cron help
Hello all,
I just installed cron on debian 7 32 bit minimal.
I'm trying to get firefox to restart every now and then while imacros is started with it.
(Sometimes I come back and firefox is magically disappeared, probably crashed.)
First I tried:
run.sh
#!/bin/sh
while [ true ]
do
sh commands.sh
sleep 3600
done
Plus commands.sh:
pkill -9 iceweasel;
firefox imacros://run/?m=emailrelog.iim;
However, I got a error with "done" command, i tried bash and sh to start the script, same error.
So I tried just "bash commands.sh", it worked, but I need it to be automatically done every hour.
Then I thought, maybe I use cron.
In the process I realized I needed a display selected so I tried the following.
Then I tried:
1 * * * * export DISPLAY=:1 && /bin/bash commands.sh
1) After I save the file, do I have to reboot computer or run a command?
2) Any other suggestions in other ways I can get my firefox to restart with imacros running?
I tried a good 3-4 hours and I'm hoping the community can lend a helping hand.
Thank you for all your help!
Have a nice day! ^_^
Comments
I'm stuck at the part where you want Firefox to restart by itself - presumably when you're not there. Why?
Okay let me try explain.
1) I save the imacros to a google drive folder, this way I can edit it remotely. (So I am not on desktop)
2) The imacros automates task for me, which I can change without being at my computer.
3) If firefox does not restart, then even though I change my imacros, firefox will be crashed/closed. My task does not complete automatically.
@Ole_Juul Could you help me out please?
1) No you don't, if you used "crontab -e" instead of editing the file by yourself.
2) This script looks good. However you may want to find firefox before trying to restart it. Don't know if it's your intension or not.
I guess you probably need to redirect the stdout, stderr, or better stdin to the blackhole /dev/null to avoid the process from being hooked to a terminal.
Thank you, I will try that.
Thank you too, will try this out aswell.
When I wrote my backup scripts on ubuntu 14.04, I had no idea why cron wouldn't execute a backup script with command "bash /path/to/backup.sh".
After googling around it needed a PATH=/whatever/ variable inside the script, which differs on my most OS-s.
Try running
to find your PATH.
On my debian wheezy boxes, the first 3 lines look like this:
Compare that to debian jessie desktop:
My script runs fine, so try the PATH below #!/bin/bash
Clearly, your
command.sh
script is usingbash
features that are simply not present insh
.Change your original script's
sh command.sh
line tobash command.sh
and it should work.My advice is to forget about
cron
entirely. To script something that runs periodically, I use exactly the technique of your first script (and stick an invocation in/etc/rc.local
if it must be started at boot).I second this, had to add "PATH" in my scripts (which are called by cron) too.