LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 07-29-2015, 05:29 AM   #1
tranphat
Member
 
Registered: Dec 2013
Posts: 86

Rep: Reputation: Disabled
Linux shell script for stop/start Tomcat


Dear all,

I have 1 small problem with the script for start/stop tomcat server.

--------- Here is my start command ------------

start() {
pid=$(tomcat_pid)
if [ -n "$pid" ]
then
echo "Tomcat is already running (pid: $pid)"
else
echo "Starting tomcat"
/bin/su -p -s /bin/sh $TOMCAT_USER $TOMCAT_HOME/bin/startup.sh > /dev/null 2>&1
fi
return 0
}

-------- Here is how I call the command --------
case $1 in
start)
start
rc_status -v
;;
stop)
stop
rc_status -v
;;

restart)
stop
sleep 5
start
;;
-------------------------------

The script above works fine, but: the message "done" is not on the same line with "Starting Tomcat"

tomct2v:~ # /etc/init.d/tomcat7 start
Starting tomcat
done

Are there any ways to make "Starting tomcat" and "done" on the same line?

Last edited by tranphat; 07-29-2015 at 05:32 AM.
 
Old 07-29-2015, 05:42 AM   #2
wpeckham
LQ Guru
 
Registered: Apr 2010
Location: Continental USA
Distribution: Debian, Ubuntu, RedHat, DSL, Puppy, CentOS, Knoppix, Mint-DE, Sparky, VSIDO, tinycore, Q4OS,Manjaro
Posts: 5,509

Rep: Reputation: 2656Reputation: 2656Reputation: 2656Reputation: 2656Reputation: 2656Reputation: 2656Reputation: 2656Reputation: 2656Reputation: 2656Reputation: 2656Reputation: 2656
RTFM

Check the man page for 'echo'.

All you need do is suppress the output of a newline.
In current GNU versions of echo, and the bash internals, the -n parameter should help.
 
1 members found this post helpful.
Old 07-29-2015, 10:48 PM   #3
tranphat
Member
 
Registered: Dec 2013
Posts: 86

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by wpeckham View Post
Check the man page for 'echo'.

All you need do is suppress the output of a newline.
In current GNU versions of echo, and the bash internals, the -n parameter should help.
Hello wpeckham,

It works, thank you so much
 
  


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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to start and stop the tomcat individual application in linux ?? jags1984 Linux - Server 2 04-20-2013 10:45 AM
How to start and stop the tomcat individual application in linux ?? jags1984 Linux - Newbie 9 04-18-2013 01:28 PM
stop script used to stop tomcat server is working intermittently BhaktiK Linux - Server 4 03-15-2013 09:38 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 10:13 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