LinuxQuestions.org
Visit Jeremy's Blog.
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 04-29-2014, 11:24 PM   #1
apss_evaluator
Member
 
Registered: Mar 2012
Posts: 115

Rep: Reputation: Disabled
trying to mix jboss4 stop and start to one script <BASH>


Hi scripters,

I was trying to mix up 2 script files(start/stop.sh) to one. I'm just new to this stuff and has been experimenting since yesterday. Can you guys help me on what I missed.

the script goes with this:
* reports current PID
* stop jboss once it got the PID
* mv logs as backup # mv log log.$(date +%d%m%Y).$(date +%R:%S)
* start jboss
* reports its new PID

attached here is the newbie script
Attached Files
File Type: txt test_script.txt (1.1 KB, 1 views)

Last edited by apss_evaluator; 04-29-2014 at 11:27 PM.
 
Old 04-29-2014, 11:26 PM   #2
apss_evaluator
Member
 
Registered: Mar 2012
Posts: 115

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by apss_evaluator View Post
Hi scripters,

I was trying to mix up 2 script files(start/stop.sh) to one. I'm just new to this stuff and has been experimenting since yesterday. Can you guys help me on what I missed.

the script goes with this:
* reports current PID
* stop jboss once it got the PID
* mv logs as backup
* start jboss
* reports its new PID

attached here is the newbie script
seems my attachment is too messy, let me just paste it here

APP=jboss
APP_PAT='program.name=run.sh'
CARRIER=sarisari
MyStatus()
{
PID=`/bin/ps auxww | /bin/grep "${APP_PAT}" | /bin/grep "${CARRIER}" | /bin/grep -v grep | /bin/awk '{print $2}'`
if [ -z $PID ]; then
PID=0
fi
}

loop_status()
{
sleep 2
for i in 1 2 3 4 5 6 7 8 9; do
MyStatus
if [ "$PID" -eq "0" ]; then
echo "- stopped"
exit 0
fi
sleep 2
done
}

echo -n "Checking ${APP} for ${CARRIER} "
MyStatus
if [ "$PID" -eq "0" ]; then
echo "- not running"
exit 0
fi
echo ""
echo "Stopping ${APP} for ${CARRIER} (running with pid $PID)"
cd /opt/msp/pkg; ./jboss-${CARRIER}.init stop
loop_status
echo "- Still running"
echo "Issuing kill -9"
kill -9 $PID
loop_status
echo "jboss was killed moving log folder now"
mv /opt/msp/pkg/jboss-${CARRIER}/server/default/log log.$(date +%d%m%Y).$(date +%R:%S)
# Start Jboss4
sleep 3
echo "Starting ${APP} for ${CARRIER}"
cd /opt/msp/pkg; ./jboss-${CARRIER}.init start
echo "${APP} for ${CARRIER} (is now running with pid $PID)"
# End of Start script
 
  


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
start script bash when system start,stop,reeboot, how ?? melmar Linux - General 4 12-10-2009 07:58 AM
bash script start gedit but don't stop there Watchin Linux - General 7 10-30-2009 01:39 AM
AWK- processing data inside start/stop pairs but ignoring start/stop lines cliffoij Programming 2 10-15-2008 07:17 AM
Start and stop a bash script based on network activity? creativetweak Linux - Software 8 05-04-2008 11:28 PM
using cron to start and stop a bash script monty Linux - Software 2 03-20-2006 03:30 PM


All times are GMT -5. The time now is 06:10 AM.

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