2

I am looking for a script that would rotate weblogs on apache. I'd like to schedule the script over cron so it could run periodically and rotate access_log and error_log for all websites on the server.

Thanks, Mark

drAlberT
  • 10,949
  • 7
  • 39
  • 52

2 Answers2

5

install and configure logrotate

drAlberT
  • 10,949
  • 7
  • 39
  • 52
4

Another good tool is Cronolog

cronolog is a simple filter program that reads log file entries from standard input and writes each entry to the output file specified by a filename template and the current date and time. When the expanded filename changes, the current file is closed and a new one opened. cronolog is intended to be used in conjunction with a Web server, such as Apache, to split the access log into daily or monthly logs.

Example Configuration:

 CustomLog "|/usr/sbin/cronolog /web/logs/%Y/%m/%d/access.log"
 ErrorLog  "|/usr/sbin/cronolog /web/logs/%Y/%m/%d/errors.log" 

Will produce and rotate logs automaticlly to:

 /web/logs/2009/09/25/access.log
 /web/logs/2009/09/25/errors.log 
rkthkr
  • 8,618
  • 28
  • 38