Question

I want to clear my Apache log without stopping apache or anything like that, but I have a problem while apache's running I can not edit the active log file.

I attempted some solutions but all is not good, or it just does not work - for example:

cat /dev/null > /path/to/log.log

It works but it kills the CPU.

Now I want to know has anybody got a good solution for clearing log files or creating a new log file with a new name every N hours which doesn't kill the CPU,RAM,etc ...

What can I do? Please give me a solution :((

Kind regards.

Was it helpful?

Solution

Install and set up logrotate, assuming you are on a debian or ubuntu distribution do this :

$ sudu apt-get install logrotate

This is an "industry standard" solution for what you want to achieve.

Recommended reading:

  1. http://articles.slicehost.com/2010/6/30/understanding-logrotate-on-ubuntu-part-1
  2. http://articles.slicehost.com/2010/6/30/understanding-logrotate-on-centos-part-1
  3. https://unix.stackexchange.com/questions/66292/learning-about-general-logging-logrotation-on-linux
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top