From: | Reiner Dassing <dassing(at)wettzell(dot)ifag(dot)de> |
---|---|
To: | Sandeep Gaikwad <sgaikwad(at)vertex(dot)co(dot)in> |
Cc: | pgsql-sql(at)postgresql(dot)org |
Subject: | Re: How to check postgres running or not ? |
Date: | 2004-09-20 07:20:03 |
Message-ID: | 414E84A3.8020200@wettzell.ifag.de |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
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
From | Date | Subject | |
---|---|---|---|
Next Message | T E Schmitz | 2004-09-20 08:04:26 | Re: ORDER BY and NULLs |
Previous Message | Richard Sydney-Smith | 2004-09-20 03:16:47 | Test for file exists? |