From: Reiner Dassing <dassing@wettzell.ifag.de>
To: Sandeep Gaikwad <sgaikwad@vertex.co.in>
Cc: pgsql-sql@postgresql.org
Subject: Re: How to check postgres running or not ?
Date: Mon, 20 Sep 2004 09:20:03 +0200
Message-ID: <414E84A3.8020200@wettzell.ifag.de> (raw)
References: <414A7395.8070503@vertex.co.in>
Hello!
Our check procedure on TRU64 UNIX is:
checkmasterdaemon
if [ $? -eq 1 ]; then
# Try to connect to postgres by selecting tables
TABELLEN=`/pg/postgresql-7.4.3/bin/psql -h postgres -c 'select datname from pg_database' postgres postgres 2>/dev/null`
if [[ "X$TABELLEN" = "X" ]];then
echo "check failed for postmaster"
exit 1
else
# echo "postmaster is running"
fi
else
echo "check failed for postmaster"
exit 1
fi
where :
checkmasterdaemon () {
MASTER_PID=$(getmasterpid)
if [ "X$MASTER_PID" = "X" ]; then
#echo "Postmaster is not running"
ret=0
else
PS_OUT=`ps -o comm,pid -p "${MASTER_PID}"`
PID=`echo $PS_OUT | awk '/postgres/ {print $4}'`
#echo $PID
if [ "X$MASTER_PID" != "X$PID" ]
then
#echo "Postmaster (${MASTER_PID}) does not exist (any more)"
ret=0
else
ret=1
fi
fi
return $ret
}
getmasterpid () {
if [[ -r ${PIDFILE} ]]
then
MASTER_PID=`head -n 1 ${PIDFILE}`
echo $MASTER_PID
else
echo ""
fi
}
--
Mit freundlichen Gruessen / With best regards
Reiner Dassing
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: dassing@wettzell.ifag.de, sgaikwad@vertex.co.in
Subject: Re: How to check postgres running or not ?
In-Reply-To: <414E84A3.8020200@wettzell.ifag.de>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox