Linux - ServerThis forum is for the discussion of Linux Software used in a server related context.
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.
Introduction to Linux - A Hands on Guide
This guide was created as an overview of the Linux Operating System, geared toward new users as an exploration tour and getting started guide, with exercises at the end of each chapter.
For more advanced trainees it can be a desktop reference, and a collection of the base knowledge needed to proceed with system and network administration. This book contains many real life examples derived from the author's experience as a Linux system and network administrator, trainer and consultant. They hope these examples will help you to get a better understanding of the Linux system and that you feel encouraged to try out things on your own.
Click Here to receive this Complete Guide absolutely free.
Hey guys i've had my dedicated server for about 16 months now and my log files are huge and I host a few small sites but one of them is quite large and can get a log file (access.log and error.log) of 1-2gb a month so over a year can take up almost 30gb just for that site so I clean them out regularly but I'm wanting a more automated way to do this
i've been thinking of using the find command using something like this but it isn't working
Install the logrotate software from your distribution's software package repository. It will probably already have a default configuration. It generally runs from the system's (root's) crontab files located in the /etc directory. Once it's installed the startup files explain how to customize it.
Most distributions come with logrotate already installed and configured by default. What distribution and version are you using?
Here the main configuration file is /etc/logrotate.conf but there are more files in /etc/logrotate.d to make fine tuning adjustments to logrotate's behavior.
Still. I'm surprised that it wasn't automatically running by default when you installed your OS.
Last edited by stress_junkie; 11-14-2010 at 08:51 PM.
Check to see if logrotate is already in the system's crontab files.
Code:
$ find /etc/cron* -type f -exec grep -H logrotate {} \;
/etc/cron.daily/logrotate:test -x /usr/sbin/logrotate || exit 0
/etc/cron.daily/logrotate:/usr/sbin/logrotate /etc/logrotate.conf
/etc/cron.daily/exim4-base: logrotate -f /etc/logrotate.d/exim4-paniclog
/etc/cron.monthly/standard:# rotation of wtmp and btmp taken over by logrotate
If it is then it should be running already. Then the question is why isn't it already rotating your http log files. You can see that these crontab files when logrotate will run. Look in /etc/logrotate.d and you will see that there is a separate file for each log file maintained by logrotate.
/etc/cron.daily/logrotate:test -x /usr/sbin/logrotate || exit 0
/etc/cron.daily/logrotate:/usr/sbin/logrotate /etc/logrotate.conf
/etc/cron.monthly/standard:# rotation of wtmp and btmp taken over by logrotate
and after looking in /etc/logrotate.d/apache2 i see this line at the top:
Initially I would just add the full path to this year's web.logs. You can find out later if logrotate will follow a symlink. I imagine it will but I don't know. You could do two or three a day to make it more bearable and to make sure that logrotate doesn't have too much work to do the first time it processes each web site's logs.
I just noticed that you have your OS in your signature. Ooops.
Last edited by stress_junkie; 11-14-2010 at 09:20 PM.
Initially I would just add the full path to this year's web.log. You can find out later if logrotate will follow a symlink. I imagine it will but I don't know.
well the problem is there monthly not yearly and there's 18 sites :/
Quote:
Originally Posted by stress_junkie
I just noticed that you have your OS in your signature. Ooops.
Then test it tonight to see if it will follow the symlink. That at least will get this month's log files rotated and it will automatically move to each new month's log files.
Quote:
Originally Posted by steve51184
and there's 18 sites :/
That wouldn't be a problem if you had done this from the beginning.
I don't think there's any way around the fact that you have some manual maintenance to do for the old log files. Maybe you could do something like this for the old ones
Code:
find /var/www/web* -type f -name *log -exec gzip {} \;
Maybe add a condition in the find command to only do files that are older than 30 days so you don't mess up the current log files.
Mind you logrotate will normally delete old log files so you could just delete old ones yourself instead of compressing them. Log file retention is configurable on a per log basis just in case you never want log files deleted. You don't have to have the old logs compressed either if you'd rather keep them in readable format. You could just have a new log started each day and leave the old log in its normal format and never have any logs deleted.
The more I think about it the more I think that's what you want to do. But logrotate won't split up the old log files. You'd probably want to use something like sed to do that.
Last edited by stress_junkie; 11-14-2010 at 09:41 PM.
sounds to me like you want to simply remove these log files to free up hard drive space and your running ubuntu with apache; it should be quite easy. I am running maverick and all my error and access logs are in "/var/log/apache2/" . Delete away if you don't want the history of your webserver and just want disk space. You are reporting some serious log sizes, you can change the way apache makes logs if you are interested... If you are deleting these files through some GUI or anything remember to empty the trash.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.