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 derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Cron problem 1

Status
Not open for further replies.

zaxxon

MIS
Dec 12, 2001
226
DE
Hi,

I have to edit 2 crontabs on an AIX box. The 1st is that of root, the other is of the user foo. I have a script that cleans off old entries I inserted before and appends new cron entries to the end off the crontabs. This works fine, but the problem is, that the cron-Daemon doesn't recoginze that there has been any changing to the crontabs and will run with the old crontab information, even an crontab -l will show the new appended instructions. If you do a crontab -e on the altered crontab and you save the file, a signal will be sent to the cron-Daemon to make it recognizing the new instructions and read the crontab.

All this updating of the crontabs occurs at night via shell scripts so there is no crontab -e possible. I read, that you can do crontab <filename> and it will overwrite the original crontab under /var/spool/cron/crontabs. The problem is, that this only works for root, as doing it with su - foo -c "crontab /var/spool/cron/crontabs/foo" will complain about the permissions on the file, which are root:cron. I don't want to change the permissions at all but I would like to have my altered crontab of the non-root user to be recognized.
I also tried a -SIGHUP ie. kill -1 on the cron-Daemon, no chance. I searched SMITTY if I could do a refresh -s on cron but that is not available in the list.

Help is very appreciated, thanks in forward.

On Linux it works with just overwriting or appending to the crontab of non-root users :-/
But Linux is no option at the moment.

laters
zaxxon
 
the AIX way was to use crontab -e to do your changes. the other way is to refresh /restat the crond so it will re-read the crontabs
 
what if you did a grep for the cron kill cron is set to respawn so it should work with the new entries
 
A kill on the cron worked, thanks a lot for your help :)

laters
zaxxon
 
From what you've posted, I'm assuming that the script that modifies your crontabs is running as root.

Given that, a less violent fix would be to simply "chown foo crontab" before executing the "su - foo -c ...." line.



Rod Knowlton
IBM Certified Advanced Technical Expert pSeries and AIX 5L

 
look here... do this:

get crontab:
crontab -l > cronfile

edit tmp file with scripts, i like sed:
sed 's/junk/goodstuff/g' cronfile > cronfile.out

apply new file using cron daemon:
crontab cronfile.out

using the file parameter with crontab command will use new file as crontab and kick cron daemon in the pants as well. less messy and error-prone.

IBM Certified -- AIX 4.3 Obfuscation
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top