LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
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, 10: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, 23 views)

Last edited by apss_evaluator; 04-29-2014 at 10:27 PM.
 
Old 04-29-2014, 10: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



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

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 10:07 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
Open Source Consulting | Domain Registration