Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I have a bunch of ec2 instances running web services; every hour I want to copy the logs back to S3. Which works perfectly well.

But, it appears if I move the logs and then touch a new file, or just write the contents to 0 Apache stops writing the logs from that point.

How is it best to do this?

share|improve this question

2 Answers 2

up vote 4 down vote accepted

Log files are accessed through their file descriptor (inode), not their name.

To rotate apache logs safely you must re-create the log file and then restart apache.

Most distros come with apache logrotate settings preconfigured; take a look at those.

share|improve this answer

Usually, the logrotate scripts issue a reload (send SIGHUP) to the running process after doing the logrotation and creating a new log file. This enables the running process (apache in your case) to reopen the log file and continue to write logs to the right file descriptor.

share|improve this answer
    
The standard apache logrotate scripts run differently, because apache includes a restart command that does not close any connections. –  adaptr Nov 30 '11 at 13:52

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.