Icarus
09-30-2002, 05:15 PM
Had an odd probelm with a cron job script this morning that baffles me of why...
I've been using a script for months to clean out a bunch of log files, some of which tend to become huge after a while (largest gets to 54MB after 2 months).
The script has been giving me no problems so I decided to add it to cron so I don't have to remember to run it every month or two. And last night was the first time it ran via cron...
it ran into some kind of error and proceeded into a loop of mailing errors to root. These mailings are relayed to the Exchange server and then to the mailboxes of me and my supervisor. He got into work 15 minutes before I did (normal) and found 33000 emails from cron:eek:
He called me as I was just about there and told me 'something is not right' :)
I ended up having to kill cron to stop it generating the messages and manually removing over 6000 remaining messages from the /usr/spool/mqueue...
The script is set to run /usr/sh and cron runs scripts with sh so I don't see where it blew up...here's how the script starts
##!/usr/sh
cd /usr/tmp
#compress the jobs log files
gzip -v CreditCd.log
gzip -v Priority.log
gzip -v cst.log
gzip -v cst1.log
gzip -v cst2pm.log
I notice that I have ## at the begining...I don't know why, see that as being bad??
the error messages were...
/usr/sbin/logclean.sh[6]: gzip: not found.
...
...
...
mv: CreditCd.log1.gz: cannot access: No such file or directory
....
The mv is later in the script, I've check for permission problems (none) and if it wasn't in /usr/sbin it would of not been able to start it in the first place...
Is my script FUBAR or is it a probelm with cron running it for some reason...I thought that cron ran scripts as root
I've been using a script for months to clean out a bunch of log files, some of which tend to become huge after a while (largest gets to 54MB after 2 months).
The script has been giving me no problems so I decided to add it to cron so I don't have to remember to run it every month or two. And last night was the first time it ran via cron...
it ran into some kind of error and proceeded into a loop of mailing errors to root. These mailings are relayed to the Exchange server and then to the mailboxes of me and my supervisor. He got into work 15 minutes before I did (normal) and found 33000 emails from cron:eek:
He called me as I was just about there and told me 'something is not right' :)
I ended up having to kill cron to stop it generating the messages and manually removing over 6000 remaining messages from the /usr/spool/mqueue...
The script is set to run /usr/sh and cron runs scripts with sh so I don't see where it blew up...here's how the script starts
##!/usr/sh
cd /usr/tmp
#compress the jobs log files
gzip -v CreditCd.log
gzip -v Priority.log
gzip -v cst.log
gzip -v cst1.log
gzip -v cst2pm.log
I notice that I have ## at the begining...I don't know why, see that as being bad??
the error messages were...
/usr/sbin/logclean.sh[6]: gzip: not found.
...
...
...
mv: CreditCd.log1.gz: cannot access: No such file or directory
....
The mv is later in the script, I've check for permission problems (none) and if it wasn't in /usr/sbin it would of not been able to start it in the first place...
Is my script FUBAR or is it a probelm with cron running it for some reason...I thought that cron ran scripts as root