LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Solaris / OpenSolaris (https://www.linuxquestions.org/questions/solaris-opensolaris-20/)
-   -   Log rotation for my application logs (https://www.linuxquestions.org/questions/solaris-opensolaris-20/log-rotation-for-my-application-logs-927327/)

parteekM 02-03-2012 12:04 AM

Log rotation for my application logs
 
hi,
my application logs grow at very high rate, i dont know how to use log rotation for those in solaris.
What i want is that:
When the log file size exceeeded 300 mb i want to make it empty.
Regards,
Parteek Makkar

EricTRA 02-03-2012 12:16 AM

Hello,

I don't know how it works in Solaris but if you have the logrotate package installed the best place to start would be the man page for logrotate:
Code:

man logrotate
A quick search also turned up this. I'm sure Google can come up with a lot more on the subject.

Kind regards,

Eric

yooy 02-03-2012 12:24 AM

have you tred to remove it with rm in crontab? maybe you will need then to replace it with empty log file.

EricTRA 02-03-2012 12:36 AM

Quote:

Originally Posted by yooy (Post 4592493)
have you tred to remove it with rm in crontab? maybe you will need then to replace it with empty log file.

Hi,

Could you elaborate a bit on what you mean? I don't see the relationship between disabling logrotate in cron and replacing a log file. But maybe that's just me. If you don't have anything constructive to add, please don't post.

Kind regards,

Eric

yooy 02-03-2012 12:47 AM

I thought he want to make some free space periodically.

EricTRA 02-03-2012 01:25 AM

Quote:

Originally Posted by yooy (Post 4592516)
I thought he want to make some free space periodically.

Hi,

I think I understand what you meant. You advised the OP to periodically run the rm command to just bluntly remove a log file in order to free up space. I misunderstood your post in that sense that I thought you were talking about disabling logrotate in cron.

Just bluntly removing a log file to free up space is very bad practice since you might need the log file later on when looking into errors! If diskspace is filling up with excessive log generation then you should look into rotating the logs, including compression, and look into WHY so much logs are being generated. Most likely there's some error or situation that needs to be fixed. If there is no error at all and you still get a lot of logs, then you might have set your partition size too small in which case you'll need to adjust that first.

Kind regards,

Eric

parteekM 02-03-2012 04:10 AM

Hi all,
Thanks for replying.
Thing is this my log file size goes upto 3 gb, and everything hangs after that and the space problem comes every next day.
So i want to rotate the logs and i want that only 2 file remains in the server
one which is old(size max-300 mb)
second which is generating logs(size max-300 mb)

Please help me.

Regards,
Parteek Makkar

EricTRA 02-03-2012 05:00 AM

Hello,

As indicated in my previous post, is there a known reason why you are generating so much log? Did you put something in debug mode and forgot to remove the debug option? Have you had a look at:
1. The links I posted?
2. If you have logrotate installed or not?
3. Research anything using Google?

Kind regards,

Eric

parteekM 02-03-2012 05:55 AM

Yes debug is on because i have few daemons running where some trasaction got stuck and we have to tail the logs.
we dont have logrotate install i dont know how to install it?
i research google but didnt get anything usefull.

Regards,
Parteek Makkar

EricTRA 02-03-2012 07:32 AM

Hi,

I think you should review your 'searching skills'. Google turned up the following in a few seconds. If you don't have logrotate installed nor know how to install it, you could use logadm which comes as standard tool as from Solaris 9.
Log rotation in Solaris using logadm
Custom logrotate in Solaris 10

Kind regards,

Eric

Blinker_Fluid 02-06-2012 12:55 PM

Quote:

Originally Posted by EricTRA (Post 4592831)
Hi,

I think you should review your 'searching skills'. Google turned up the following in a few seconds. If you don't have logrotate installed nor know how to install it, you could use logadm which comes as standard tool as from Solaris 9.
Log rotation in Solaris using logadm
Custom logrotate in Solaris 10

Kind regards,

Eric

What he said.


Basically the logadm information is kept in /etc/logadm.conf if you don't have to kill or nohup any processes that are holding open the filesystem a simple 'logadm -C <#ofcopies> -S <size> /path/to/log' is all you need.

one thing to be aware of, logadm is typically run from root's cron file so check it for how often it needs to run if you're generating a GB of logs in a day and only wanting to keep 300m and cron only executes it once a day you'll still be hitting a GB before it rolls.


All times are GMT -5. The time now is 07:52 PM.