0

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...

Jayakrishnan T
  • 298
  • 2
  • 8
  • 22

2 Answers2

0

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.

Khaled
  • 36,533
  • 8
  • 72
  • 99
  • 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 08 '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 08 '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 08 '10 at 10:49
0

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>
chocripple
  • 2,109
  • 14
  • 9
  • 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 09 '10 at 07:15