Results 1 to 10 of 10
HI All,
At present in my server the log folder was filled up and causing memory issue.
So I am planning to write a script in such a way that ...
- 06-21-2011 #1Just Joined!
- Join Date
- Jun 2011
- Posts
- 6
need to zip all the files excluding todays file
HI All,
At present in my server the log folder was filled up and causing memory issue.
So I am planning to write a script in such a way that the files which are older than 30 days will be deleted and also need to find the files which were not compressed and need to compress this file. Compression will exclude if the file was created on the same day.
I am new to Unix .Please bear me.
- 06-21-2011 #2
Already done.
Have a look at logrotate
Code:man logrotate
You must always face the curtain with a bow.
- 06-21-2011 #3Just Joined!
- Join Date
- Jun 2011
- Posts
- 6
Thanks for you help.
I gone through the man pages.I tried to with some script.
Can you please have a look
Regards,Code:"/var/log/jboss/*.log" { missingok copytruncate rotate 30 -thinking that will keep 30days files compress notifempty sharedscripts postrotate endscript }
Sreenivas A.
- 06-21-2011 #4
The "rotate 30" is ok.
I think you can omit "sharedscript, postrotate, endscript"
As there is nothing defined to be executed after rotating.
In consequence, also sharedscript does nothing.
The copytruncate will work, at the cost of loosing a few loglines (seconds at most) due to the copy process.
I cant find in a hurry, if jboss can be signaled to reopen its logfiles.
In that case, the following might help to have all loglines
Another thing:Code:compres delaycompress sharedscripts postrotate <SEND SIGNAL TO JBOSS> endscript
If you installed jboss via package manager (apt-get, yum, etc) then the chance is high, that there is already a logrotate conf for it in /etc/logrotate.dLast edited by Irithori; 06-21-2011 at 12:37 PM.
You must always face the curtain with a bow.
- 06-21-2011 #5Just Joined!
- Join Date
- Jun 2011
- Posts
- 6
Thanks for your reply.
So which means my file will look like
I think they haven't installed it from package manageer. I haven't seen any file related to jboss in logrotate.d .Code:"/var/log/jboss/*.log" { missingok rotate 30 compress delaycompress notifempty sharedscripts postrotate <SEND SIGNAL TO JBOSS> endscript }
How can I send siganl to JBOSS in postrotate section?
Regards,
Sreenivas A.
- 06-21-2011 #6
After some digging (I dont use jboss atm) at the usual places and reading specfiles/forums/deb/rpm packages,
it seems that jboss doesnt play so nice with logrotate.
This post explains it:
Why do JBoss and Logrotate create log files full of NUL characters? - Server Fault
So sorry:
It seems, the easy way via logrotate cannot be reliably implemented, and instead Log4j needs to be used.You must always face the curtain with a bow.
- 06-22-2011 #7Just Joined!
- Join Date
- Jun 2011
- Posts
- 6
Thanks Irithori.
I checked the link and found that it will rename the server.log to server.log.todaydate.
But it won't compress nor delete the older files. May be I need to logrotate to perform these two task
is it right?
Regards,
Sreenivas A.
- 06-22-2011 #8
Unfortunately, I have little experience with log4j, as our projects rarely involve java.
So I am the wrong guy from here on, sorry.
I do know, that log4j is the standard and stable java logging framework.
Most probably it can at least rotate logs.
Maybe start reading here
Apache log4j 1.2 - Short introduction to log4j
and then that
DailyRollingFileAppender (Apache Log4j 1.2.16 API)You must always face the curtain with a bow.
- 06-27-2011 #9Just Joined!
- Join Date
- Jun 2011
- Posts
- 6
HI,
with DailyRollingFileAppender we can rotate the files but we can't zip or delete the files. SO I wrote DailyRollingFileAppender to rotate the files and then for zip and delete we used the below code and placed under /etc/logrotate.d/ folder.
then I tried logrotate -f /etc/logrotate.d/jbossCode:/var/log/jboss/*.log { missingok copytruncate rotate 30 compress notifempty }
but still the files were not zipped nor deleted.
Regards,
Sreenivas A.
- 06-29-2011 #10Just Joined!
- Join Date
- Jun 2011
- Posts
- 6
any inputs please?


Reply With Quote