Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

i want to write a shell script to stop my currently running jboss applications(may more than one jboss running in one server) and rename the corresponding log files generated in the log directory.Renamed file must contain the time when the script is running,that will helps to identify that file.Please help me...

share|improve this question
1  
Doesn't it come with a logrotate config file? –  Ignacio Vazquez-Abrams Dec 8 '10 at 7:31

2 Answers 2

up vote 0 down vote accepted

You can use logrotate as suggested by Ignacio. For example, the following configuration snippet shows how to logrotate the system messages file and reloading the syslogd process. You can use prerotate and postrotate to execute scripts/commands before and after rotating the log file respectively.

/var/log/messages {
   rotate 5
   weekly
   postrotate
        /usr/bin/killall -HUP syslogd
   endscript
}

For more info, check man logrotate.

share|improve this answer
    
Thanks Mr Khaled for Your reply.But i cant kill my jboss application when my live server is working.so do u have any other idea. –  Jayakrishnan T Dec 8 '10 at 10:08
    
Usually, you don't need to stop your server. You just need to reload using the command shown killall -HUP process_name. –  Khaled Dec 8 '10 at 10:13
    
In my Live server I have More than 3 Jboss applications.If i use Killall command it will affect my live application.I want to stop a particular Jboss for checking error in that module. –  Jayakrishnan T Dec 8 '10 at 10:49

cmiiw i think you just enable logrotate on jboss-log4j.xml

<pre><code>
      <!-- A time/date based rolling appender -->
    <appender name="FILE" class="org.jboss.logging.appender.DailyRollingFileAppender">
      <errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler"/>
      <param name="File" value="${jboss.server.log.dir}/server.log"/>
      <param name="Append" value="true"/>
      <param name="Threshold" value="${jboss.server.log.threshold}"/>  
      <layout class="org.apache.log4j.PatternLayout">
         <param name="ConversionPattern" value="%d %-5p [%c] (%t) %m%n"/>
      </layout>
   </appender>
</pre></code>
share|improve this answer
    
Thank you Rikih.But i want to rotate console.log and gclog.log also.jboss-log4j.xml will not helps to rotate those log files. –  Jayakrishnan T Dec 9 '10 at 7:15

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.