Description of problem: This seems to be a change between logrotate in RHEL4 and RHEL5.1 I have an scp for my httpd logrotate conf which moves the *.1.gz off box for stat processing etc. Under RHEL4 it worked as expected, I've moved the process to a new RHEL5 server and now I am having issues with the compress arg not finishing before the postrotate is being executed. Version-Release number of selected component (if applicable): logrotate-3.7.4-7 How reproducible: intermittent, sometimes the compress will finish fast and the scp will happen without issue, sometime the compress will run long and the postrotate will run and send errors that there were no files to scp. Expected results: logrotate should wait for the compress to finish before executing the postrotate Additional info: Deailing with about 1GB daily apache log uncompressed to give you some indication of why the compress may be taking a while.
Are you sure that the compression finishes successfully? Can you see the compressed log on the original system?
Yes the Compress does finish, since I have to go back manually and move the logs off box I have to go back and scp of the *.1.gz'ed files which are always there
is there perhaps an overall timeout in the code that is saying to finish if you exceed X??
That's why I asked. There's fork; execvp; wait. So until the gzip finishes logrotate should be waiting. I'll try to investigate the problem. Please let me know in case you find out any additional information.
Nothing yet... Could you please attach your config file?
/var/log/httpd/*log { daily rotate 32 missingok notifempty compress sharedscripts postrotate /bin/kill -HUP `cat /var/run/httpd.pid 2>/dev/null` 2> /dev/null || true scp -i /root/.ssh/logsync.id_dsa logsync.3.60:webstats/webstats.lock . 2>/dev/null || scp -i /root/.ssh/logsync.id_dsa /var/log/httpd/*domainname.net_access_log.1 /root/webstats.sem logsync.3.60:webstats endscript }
sorry that was the older config.. the current config is exactly the same except it's scp'ing the *1.gz
Hi we are still having this problem, now on other systems to where we're trying to move off the .1.gz logfile using scp in the postrotate section.. please advise how we can assist you in troubleshooting this issue.
The Config: /var/log/httpd/*log { daily rotate 62 compress missingok notifempty sharedscripts postrotate /bin/kill -HUP `cat /var/run/httpd.pid 2>/dev/null` 2> /dev/null || true /root/movelog.sh endscript }
The Script I am running #!/bin/bash # couple of needed variables hostname=`hostname` filename=testdomain.cdn.fm-access_log.1.gz # md5 the rotated *.1.gz logs. cd /var/log/httpd md5sum $filename > /tmp/$hostname-md5sum.txt # Are things being touched on Admin?? if so fail, if not copy logs over scp -i /root/.ssh/movelog.id_dsa castfirelog@admin:movelog.lock . 2>/dev/null || scp -q -p -i /root/.ssh/movelog.id_dsa /tmp/$hostname-md5sum.txt /var/log/httpd/$filename /root/$hostname.sem movelog@admin:$hostname/
I should have read the documentation first... The behaviour you're observing is intentional. See the bug #167575. What confused me was the fact that the log had been copied sometimes. That's why I couldn't find anything in the code that could possibly explain the issue. It looks to be not a bug after all.
I forgot... Please change the "postrotate" keyword for "lastaction". It should solve your problem.
Okay I have changed my logrotate conf as follows. I'll follow up tomorrow and confirm that this has solved the issue. /var/log/httpd/*log { daily rotate 62 compress missingok notifempty sharedscripts postrotate /bin/kill -HUP `cat /var/run/httpd.pid 2>/dev/null` 2> /dev/null || true lastaction /root/castfirelog.sh endscript }
This did not resolve the issue, can you confirm that the way I am using the last action command is valid in Comment #13 Once again we do not have the logs copied over as they should be. However if I run the script manually now (Well after logrotation) it will do what it is suppose to do.
Using the Logrotate config from Comment #13 I get the following when I try and run logrotate manually.. [root.fmpub.net ~]# logrotate -f /etc/logrotate.d/httpd sh: line 2: lastaction: command not found please advise
(In reply to comment #15) > please advise Your script should look like this: /var/log/httpd/*log { daily rotate 62 compress missingok notifempty sharedscripts lastaction /bin/kill -HUP `cat /var/run/httpd.pid 2>/dev/null` 2> /dev/null || true /root/castfirelog.sh endscript } i.e., no postrotate, but lastaction instead. Hope this helps.
This still doesn't appear to be working correctly.. the only reason I have gotten this to work is because my script now starts with a 600 second sleep.. Is thee any logging or debugging we can turn on with Logrotate to see why this is not working?
You can start logrotate with -v parameter, which turns on verbose mode. There is also -d option that turns on the debugging mode -- i.e., only the messages are printed but no log changes are made.
Any update on this?
I think we should close this one... It's been in needinfo for quite a long time.
OK, closing