LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 06-27-2015, 01:13 PM   #1
hruday
Member
 
Registered: Jun 2015
Posts: 84

Rep: Reputation: Disabled
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/

Last edited by hruday; 06-27-2015 at 01:14 PM.
 
Old 06-27-2015, 04:24 PM   #2
Ser Olmy
Senior Member
 
Registered: Jan 2012
Distribution: Slackware
Posts: 2,445

Rep: Reputation: Disabled
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
 
Old 06-28-2015, 09:08 AM   #3
hruday
Member
 
Registered: Jun 2015
Posts: 84

Original Poster
Rep: Reputation: Disabled
@ser olmy: yeah algorithm is close enough. but how to "locate running jboss instances".?

Last edited by hruday; 06-28-2015 at 09:14 AM.
 
Old 06-29-2015, 05:40 AM   #4
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.9, Centos 7.3
Posts: 17,362

Rep: Reputation: 2377Reputation: 2377Reputation: 2377Reputation: 2377Reputation: 2377Reputation: 2377Reputation: 2377Reputation: 2377Reputation: 2377Reputation: 2377Reputation: 2377
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).
 
Old 06-29-2015, 08:10 AM   #5
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 18,889

Rep: Reputation: 4259Reputation: 4259Reputation: 4259Reputation: 4259Reputation: 4259Reputation: 4259Reputation: 4259Reputation: 4259Reputation: 4259Reputation: 4259Reputation: 4259
Quote:
Originally Posted by hruday View Post
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.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] How can I purge files logarithmically by modification date (BASH)? gunnarflax Programming 31 03-10-2013 02:45 PM
[SOLVED] Using bash script to purge rotating tcpdump files merixon Programming 5 10-20-2010 11:19 AM
Script: purge files more than N days old. Need Non Recursive Find explore.s AIX 3 12-04-2008 07:24 AM
Simple Log File Purge kellyj Linux - Newbie 3 10-03-2007 05:39 AM
Purge duplicate files in one directory smudge|lala Linux - General 8 03-30-2006 08:08 PM


All times are GMT -5. The time now is 02:30 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration