LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Purge JBOSS log files (https://www.linuxquestions.org/questions/linux-newbie-8/purge-jboss-log-files-4175546591/)

hruday 06-27-2015 01:13 PM

Purge JBOSS log files
 
I am using centOS server with two instances of JBOSS running in it.
So i need a shell script to delete log files older than x days in each instance.
for example:
ps -ef | grep jboss

i get two instances like say
/home/mypro/jboss-as-7.1.1/standalone/...
/home/newpro/SAAS-jboss-as-7.1.1/standalone/...

***And shell script should also delete log files automatically when a new instance is created.

By default logs are saved in
/home/mypro/jboss-as-7.1.1/standalone/logs/
/home/newpro/SAAS-jboss-as-7.1.1/standalone/logs/

Ser Olmy 06-27-2015 04:24 PM

So I guess the pseudo-code would look something like this?
Code:

locate running jboss instances
for var in each standalone/logs subdirectory, do:
  for log in each log older than x days, do:
    delete log
  done
done


hruday 06-28-2015 09:08 AM

@ser olmy: yeah algorithm is close enough. but how to "locate running jboss instances".?

chrism01 06-29-2015 05:40 AM

You could use 'ps -ef|grep ..' or pgrep .. but, if you have ctrl over the install or just knowledge of it, you could skip straight to the logfile dir(s).

TB0ne 06-29-2015 08:10 AM

Quote:

Originally Posted by hruday (Post 5383760)
I am using centOS server with two instances of JBOSS running in it.
So i need a shell script to delete log files older than x days in each instance. for example:
ps -ef | grep jboss

i get two instances like say
/home/mypro/jboss-as-7.1.1/standalone/...
/home/newpro/SAAS-jboss-as-7.1.1/standalone/...

***And shell script should also delete log files automatically when a new instance is created.

By default logs are saved in /home/mypro/jboss-as-7.1.1/standalone/logs/ /home/newpro/SAAS-jboss-as-7.1.1/standalone/logs/

Read the "Question Guidelines" link in my posting signature. We will be happy to HELP you, but we are NOT going to write your script FOR YOU. You are essentially asking for a handout, and have shown no effort of your own. There are many thousands of easily-found scripting tutorials to help get you started.


All times are GMT -5. The time now is 08:23 AM.