Logrotate: don't seem to be able to restart service (apache)
Linux - GeneralThis Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Logrotate: don't seem to be able to restart service (apache)
Hi guys,
I have in my server, 2 instances of apache 2.0.54.
One is relying on java's Policy Agent, one is not.
Anyway, I am trying to use logrotate to rotate the logs so as to save some space... but I realise the service is not being restarted as the process ID is the same...
the instance with pa have to be stop and then start, thus so
am I doing it wrongly?
Also, I am thinking of backing up the logs to a remote server using scp on a daily basis... but can't think of a good way to let the script copy the latest log... since the logs are being rotated and then renamed...
I stopped using logrotate for Apache a while back and now I let Apache rotate the logs itself. From the man page for rotatelogs:
Code:
CustomLog "|bin/rotatelogs /var/logs/logfile 86400" common
This creates the files /var/logs/logfile.nnnn where nnnn is the system time at which the log nominally starts
(this time will always be a multiple of the rotation time, so you can synchronize cron scripts with it). At
the end of each rotation time (here after 24 hours) a new log is started.
CustomLog "|bin/rotatelogs -l /var/logs/logfile.%Y.%m.%d 86400" common
I stopped using logrotate for Apache a while back and now I let Apache rotate the logs itself. From the man page for rotatelogs:
Code:
CustomLog "|bin/rotatelogs /var/logs/logfile 86400" common
This creates the files /var/logs/logfile.nnnn where nnnn is the system time at which the log nominally starts
(this time will always be a multiple of the rotation time, so you can synchronize cron scripts with it). At
the end of each rotation time (here after 24 hours) a new log is started.
CustomLog "|bin/rotatelogs -l /var/logs/logfile.%Y.%m.%d 86400" common
cool i didn't know you could do that.. i'll check it out.. thanks!
Your Apache is self-compiled? No problem, mine is too and logrotate works properly here.
actually my concern is if my apache is being restarted properly.
Initially I have the misconception that if i restart it, the process ID will be different.. but apparently not.. so how do I see if apache restarted successfully?
also.. for logrotate.. is it essential for the service to be restarted after rotation?
lastly.. what does the -HUP mean? does it mean that it will restart the process?
I need to use the killall on my setup. If you want to see the different effects, try it with and without, but make sure that you hit your web servers with requests before and after so you can see which log files are being used. httpd should be still running, you can use netstat to confirm it:
Code:
netstat -tunape | grep httpd
The HUP signal causes Apache to re-read its config files and re-initialise.
hi there, i've used the -HUP but to no avail. (/sbin/killall -HUP httpd)
My logs are rotated, but it won't write to the new logfiles, unless i manually restart apache.
I've now write a script to restart apache, and have point logrotate to restart it.. will know tomorrow if it works.
Meanwhile... how do you guys do it? My apache is self-compiled. I am running multiple instances of apache in the same machine, so I have to restart all of them.
The problem you're describing is the reason I use Apache's rotatelogs utility. If you manage to get it working the way you described earlier, can you post your final config please?
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.