hcclnoodles
IS-IT--Management
I have a script which goes out and installs a package on a box remotely and im trying to get it to add a cron job too..but im having a few problems, whilst it does add the entry it wont run unless I connect to the machine , crontab -e, then :wq. This re-reads the configuration file and it will now run. so i tried in my script the following methods
1) I tried to edit the cron file for root directly
ssh $mybox 'echo "0 22 * * 5 /opt/SUNWexplo/bin/explorer -q -e" >> /var/spool/cron/crontabs/root'
But i realised that the process would need to be HUP'ed to re-read this conf file so i tried adding
pkill -HUP cron
I come in the next morning and I check /var/cron/log] and nothing has run. However, as i said, if i crontab -e and then save it immediately wq) then it will work fine
2) Ok, as far as im aware the above should have worked but I thought id try another method, this according to my colleague would definately work. Output crontab -l to a temp file , append the line to the temp file and use crontab <filename>. to re-read it in...
ssh $mybox 'crontab -l > /tmp/cron1'
ssh $mybox 'echo "0 22 * * 5 /opt/SUNWexplo/bin/explorer -q -e" >> /tmp/cron1'
ssh $mybox 'crontab /tmp/cron1'
Same thing, come in next morning nothings happened, log onto box crontab -e, then immediately same it wq) and all is working ..
Does anybody have any idea on how i can get this to work
cheers
1) I tried to edit the cron file for root directly
ssh $mybox 'echo "0 22 * * 5 /opt/SUNWexplo/bin/explorer -q -e" >> /var/spool/cron/crontabs/root'
But i realised that the process would need to be HUP'ed to re-read this conf file so i tried adding
pkill -HUP cron
I come in the next morning and I check /var/cron/log] and nothing has run. However, as i said, if i crontab -e and then save it immediately wq) then it will work fine
2) Ok, as far as im aware the above should have worked but I thought id try another method, this according to my colleague would definately work. Output crontab -l to a temp file , append the line to the temp file and use crontab <filename>. to re-read it in...
ssh $mybox 'crontab -l > /tmp/cron1'
ssh $mybox 'echo "0 22 * * 5 /opt/SUNWexplo/bin/explorer -q -e" >> /tmp/cron1'
ssh $mybox 'crontab /tmp/cron1'
Same thing, come in next morning nothings happened, log onto box crontab -e, then immediately same it wq) and all is working ..
Does anybody have any idea on how i can get this to work
cheers