Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

a question about cron

Status
Not open for further replies.

hcclnoodles

IS-IT--Management
Jun 3, 2004
123
GB
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
 
Can I just clarify : the crontab is being updated, but then doesn't appear to work? I must admit I would expect the second appraoch to work.

Alan Bennett said:
I don't mind people who aren't what they seem. I just wish they'd make their mind up.
 
yep the crontab has the line appended, and if i do a crontab -l I can see it, but i assume crontab -l just reads /var/spool/cron/crontabs/root and not what the running cron process has read into memory ?

I was just thinking, do i need to issue a carriage return after my command
 
The method your colleague suggested seemed to work for me on Solaris 8.

Annihilannic.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top