SupermanInNY
Verified User
- Joined
- Sep 28, 2004
- Messages
- 419
Hi all,
I have a server with a run away script that fills the /var/log/httpd/error_log into 2GB of errors within few minutes (once it hits that error).
As such, the apache gets stuck and fails to come back online.
While the correct solution is to find the culprit script/code and fix it, the user is not fast to find it.
As a quick fix, I simply delete the error_log file and restart apache.
Then we get few days of quiet and then go through this motion again.
I am looking to automate the quick fix, but somehow I'm not able to run a cron that does that.
The idea is that if the file exceeds 500MB, it is already too big to be real and it is likely that the infinite loop is already in progress.
The cron doesn't do the trick.
If I run the file manually it runs fine, but not as a cron.
(yes, I know I'm running it against a test file,.. I'm still testing).
Any pointers on how or what I'm missing with running it as a cron?
Thanks for any insight.
-Alon.
I have a server with a run away script that fills the /var/log/httpd/error_log into 2GB of errors within few minutes (once it hits that error).
As such, the apache gets stuck and fails to come back online.
While the correct solution is to find the culprit script/code and fix it, the user is not fast to find it.
As a quick fix, I simply delete the error_log file and restart apache.
Then we get few days of quiet and then go through this motion again.
I am looking to automate the quick fix, but somehow I'm not able to run a cron that does that.
The idea is that if the file exceeds 500MB, it is already too big to be real and it is likely that the infinite loop is already in progress.
/usr/bin # vi cleanApacheErrorLogFile.sh
#!/bin/bash
test $(stat -c \%s /var/log/httpd/test.log1.tar) -gt 500000000 && /usr/sbin/apachectl stop && rm -Rf /var/log/httpd/test.log1.tar && wall wow
/usr/bin # crontab -e
*/10 * * * * /usr/bin/rdate time-a.nist.gov >date -s
0 5 * * 0 /usr/local/sysbk/sysbk -q
* * * * * root /usr/bin/cleanApacheErrorLogFile.sh
The cron doesn't do the trick.
If I run the file manually it runs fine, but not as a cron.
(yes, I know I'm running it against a test file,.. I'm still testing).
Any pointers on how or what I'm missing with running it as a cron?
Thanks for any insight.
-Alon.