Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have installed GeoSerer running with Jetty. I use monit to monitor GeoServer is running or not and I need pid in the process.

Anyone can tell me how to do that?

share|improve this question
up vote 1 down vote accepted

supposing you are using the default startup/shutdown scripts, the quick and dirty way is:

gsrvpid=`ps axuwwwww|grep GEOSERVER | grep -v grep | awk ' { print $2 ; } '`
echo $gsrvpid

(i just grepped for a pattern that should match only the process I am interested in but you may get weird results if the pattern matches something else as well)

the correct way is to wrap the startup/shutdown scripts into a init script that will save the pid somewhere in the file system cuz as we can notice the java dudes don't really care about providing good service management scripts.

startup script (very simplified):


export GEOSERVER_HOME=/root/tmp/geoserver-2.0.2
cd ${GEOSERVER_HOME} || exit
echo $$ > /var/run/
exec ./bin/

shutdown script (very simplified):

export GEOSERVER_HOME=/root/tmp/geoserver-2.0.2
cd ${GEOSERVER_HOME} || exit
rm -f /var/run/

you can get the pid of the process with

cat /var/run/

like this:

ps  www -p `cat /var/run/`
26394 pts/4    Sl+    0:12 /usr/lib/jvm/java-6-sun/bin/java -DGEOSERVER_DATA_DIR=/root/tmp/geoserver-2.0.2/data_dir -Djava.awt.headless=true -DSTOP.PORT=8079 -DSTOP.KEY=geoserver -jar start.jar

or like this:

kill -0 `cat /var/run/` && echo "my geo thing is alive"
my geo thing is alive
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.