Sponsored Content
Top Forums Shell Programming and Scripting How to check for and start the Tomcat using a script Post 302350409 by EAGL€ on Thursday 3rd of September 2009 06:01:38 PM
Old 09-03-2009
Sorry for late reply,

I hope it'll give you an idea to do it. I checked a production machine which is working over tomcat but i coudlnt be sure what is the right command to see that tomcat is up? but you might do it a few ways.
1. Tomcat's default port is 8080. u can grep it and use port status in comparision loop.

Code:
#!/bin/bash
STAT=`netstat -na | grep 8080 | awk '{print $7}'`
if [ "$STAT" = "LISTEN" ]; then
echo "DEFAULT TOMCAT PORT IS LISTENING, SO ITS OK"
elif [ "$STAT" = "" ]; then 
echo "8080 PORT IS NOT IN USE SO TOMCAT IS NOT WORKING"
## only if you defined CATALINA_HOME in JAVA ENV ##
cd $CATALINA_HOME/bin
./startup.sh
fi
RESULT=`netstat -na | grep 8080 | awk '{print $7}' | wc -l`
if [ "$RESULT" = 0 ]; then
echo "TOMCAT PORT STILL NOT LISTENING"
elif [ "$RESULT" != 0 ]; then
echo "TOMCAT PORT IS LISTENINS AND SO TOMCAT WORKING"
fi

2. You can grep something more reliable than a port number and then you can modify the script according to that data. Maybe you grep "catalina" etc..

Last edited by EAGL€; 09-03-2009 at 07:05 PM.. Reason: forget st to add
This User Gave Thanks to EAGL€ For This Post:
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Problem with Unix script to start remote Tomcat

I have Tomcat installed on a Unix box and I need to start it remotely from another Unix box. Tomcat is started using a script. When this script is run locally everything is fine. When I run the same script from remote box, tomcat starts but the command running the script does not terminate.:( ... (2 Replies)
Discussion started by: shrgh
2 Replies

2. Web Development

Allow multiple users to start/stop tomcat

Hi, I have the user who runs tomcat: tomcat:tomcats I want to have another user who will be able to start and stop tomcat process. Is this possible? Thanks, Bianca (1 Reply)
Discussion started by: potro
1 Replies

3. Solaris

How to start tomcat with 2 jdk?

Current platform: Sun OS 5.9 Solaris isainfo -v 64-bit sparcv9 applications 32-bit sparc applications Problem: Fail to start tomcat server ps -ef | grep tomcat nothing displays... Steps: Installed jakarta-tomcat-5.0.30 Installed jdk 1.6 and set path in profile... (11 Replies)
Discussion started by: sbox
11 Replies

4. Shell Programming and Scripting

UNIX script to check file and start the informatica server

Hi Rockers, I hope u r dng good one. I have a one question is in unix with informatica . I need a unix script to check whether particular file exists in the folder , If it means we have a informatica server , so we can start the informatica server by accessing that file. Every week we have... (0 Replies)
Discussion started by: gurukrishnan
0 Replies

5. Shell Programming and Scripting

tomcat automaticaly stop in menu script

i have a problem with the code I created (see below). a. when I logged in as root and su to tomcat, i can execute all options. when I press X, it will exit properly. b. when I logged in directly as user1, I can execute also all options. if I press X i will logout automatically to putty.... (2 Replies)
Discussion started by: lhareigh890
2 Replies

6. UNIX for Advanced & Expert Users

Is it Possible to Start Tomcat Manager using command prompt!

Hi All, wget http://<username>:<password>@<hostname>:<port>/manager/list -O - -q using this command i can able to stop , start , reload everything i can able to do once i start the tomcat , now i have some doubt legends. 1. Is this is a secure way using wget to start, stop, reload the... (0 Replies)
Discussion started by: anishkumarv
0 Replies

7. Shell Programming and Scripting

Help scripting to start, check, and restart processes

Here it goes from my unexperienced point of view. I am using CentOS 5.6. I have a Java based server that needs to be running 24/7/365. To begin from the machine the server is on rebooting; I SSH in to a shell, cd to the server dir, screen -S server1, and execute ./exec (listed below) in the screen.... (12 Replies)
Discussion started by: MacG32
12 Replies

8. Solaris

Tomcat..Unable to deploy application remotely in tomcat

Hi, We have upgrade tomcat from 5.0.20 to 7.0.33 and made changes to server.xml file according to newer version.. how ever the upgrade went fine and now i am unable to deploy application remotely.. it is giving 403 access denied error.. we have seperate appbase directory mentioned in server.xml..... (0 Replies)
Discussion started by: phani4u
0 Replies

9. Shell Programming and Scripting

Montioring Script Tomcat catalina.out

Hi, I need to monitor the tomcat log file called "Catalina.out" for any errors like out of memory,JDBC exceptions,broken pipe any other errors and exceptions The script should monitor this file and send a mail instantly and create a text file with errors day to day. Iam using Solaris... (3 Replies)
Discussion started by: chaithanyaa
3 Replies

10. UNIX for Advanced & Expert Users

Script monitor website wth default tomcat script

Hi all, on our application server we have the following script that monitor the status of the website, my problem here is that i have edite the retries from 3 to 5, and the timewait to 120 second, so the script should check 5 times every 2 minutes, and if the fifth check fails it must restart... (0 Replies)
Discussion started by: charli1
0 Replies
ZGREP(1)						      General Commands Manual							  ZGREP(1)

NAME
zgrep - search possibly compressed files for a regular expression SYNOPSIS
zgrep [ grep_options ] [ -e ] pattern filename... DESCRIPTION
Zgrep invokes grep on compressed or gzipped files. These grep options will cause zgrep to terminate with an error code: (-[drRzZ]|--di*|--exc*|--inc*|--rec*|--nu*). All other options specified are passed directly to grep. If no file is specified, then the standard input is decompressed if necessary and fed to grep. Otherwise the given files are uncompressed if necessary and fed to grep. If the GREP environment variable is set, zgrep uses it as the grep program to be invoked. EXIT CODE
2 - An option that is not supported was specified. AUTHOR
Charles Levert (charles@comm.polymtl.ca) SEE ALSO
grep(1), gzexe(1), gzip(1), zdiff(1), zforce(1), zmore(1), znew(1) ZGREP(1)
All times are GMT -4. The time now is 09:41 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy