Best unofficial Apache Server developers community
Username
Forgot password?
Sign in with Twitter account
Sign in with Facebook account

Rotate apache logs based on file size in Ubuntu

1

64 views

I have three sites on my server and their logs (Apache logs) are in their root folder not in /var/log. I need a script that rotates the access_log and error_log base on their file size for example rotates them when their file size exceeds 1G .

Server's OS is Ubuntu.

I have a basic skill of shell programing but good talent in learing ;) would you help me in this issue?

asked June 25, 2011 2:04 am CDT
hd
posted via StackOverflow

1 Answer

0
 

logrotate can be configured on only rotate when logs exceed a certain size, see the minsize option. Typically logrotate runs daily though, if you wanted to rotate when the logfile was more or less exactly 1GB, you might need a script which watches the logfile and triggers logrotate when it exceeds your limit.

Alternatively, you could stick with daily rotation of smaller logfiles, but have a postrotate script which concatenates the rotated logs together into 1GB clumps of data.

answered June 25, 2011 2:23 am CDT

Your answer

Join with account you already have


Sign in with Twitter account
Sign in with Facebook account
Sign in with Google Friend Connect

Preview
Similar questions