postrotate in logrotate
Hi All,
I am a newbie to linux and working on RHEL. I tried to implement logrotation for apache logs and stuck at restarting a process after apache restart.My script is as below /usr/local/apache2/access_log { weekly rotate 25 compress create postrotate /usr/local/apache2/bin/apachectl restart > /dev/null 2>&1 if [ -f /usr/local/apache2/logs/httpd.pid ];then sudo -u reto ./usr/local/Misc/Start_Stream.sh > /dev/null 2>&1 fi endscript } when i execute this script with root user, Apache is getting started but the script in the condition which has to be run with reto user is not executing..Any inputs please. Thanks in Advance. |
Here's one that does work:
Code:
/var/log/httpd/*_log { Code:
/usr/local/apache2/access_log { You would edit the /etc/rc.d/rc.httpd restart to your system's actual start up program (the one that executes at boot) if it includes the restart directive, or simply to edit the apachectl line, adding the -k option: Code:
/usr/local/apache2/bin/apachectl -k restart > /dev/null 2>&1 Code:
if [ -f /usr/local/apache2/logs/httpd.pid ];then See Stopping and Restarting at http://httpd.apache.org/docs/2.2/stopping.html; essentially, the -k option sends a TERM signal to the running process causing it to kill off all of its children. Can't hurt, might help. You might also want to change the size=5M (which is a test for the log size being 5 megabytes) to some other value depending upon how large your logs get in a week. Hope this helps some. |
logrotate like cron really requires full/absolute paths to ensure stuff will run
Code:
sudo -u reto ./usr/local/Misc/Start_Stream.sh > /dev/null 2>&1 |
All times are GMT -5. The time now is 04:55 PM. |