Neues Script CheckPid - prueft PID-Files, und loescht sie,
wenn der Prozess nicht existiert, bzw. gibt ein Return <>0 wenn der Prozess existiert git-svn-id: svn://svn.compuextreme.de/Viitor/V963/Viitor_upstart@6196 504e572c-2e33-0410-9681-be2bf7408885
This commit is contained in:
parent
c82ef13b01
commit
d459433633
28
sbin/CheckPid
Executable file
28
sbin/CheckPid
Executable file
@ -0,0 +1,28 @@
|
||||
#!/bin/bash
|
||||
|
||||
PIDFILE=$1
|
||||
|
||||
if [ ! ${PIDFILE} ]; then
|
||||
echo "Usage: $0 <pidfile>"
|
||||
exit 10
|
||||
fi
|
||||
|
||||
PID=$(cat ${PIDFILE})
|
||||
PSNAME=$(ps -ef|awk '{ if ( $2 == "'${PID}'" ) print $8 }'|cut -d "." -f1)
|
||||
SEEKNAME=$(basename ${PIDFILE}|cut -d"." -f1)
|
||||
if [ "${PSNAME}" ]; then
|
||||
if echo ${SEEKNAME}|grep -q $(basename ${PSNAME}); then
|
||||
logger -p info -t upstart "Found running Prozess ${PSNAME} for ${PIDFILE}; aborting startup"
|
||||
exit 2
|
||||
else
|
||||
logger -p info -t upstart "PIDFILE ${PIDFILE} does not point to the correct running prozess"
|
||||
logger -p info -t upstart "cleanup ${PIDFILE} and start the prozess"
|
||||
rm ${PIDFILE}
|
||||
exit 0
|
||||
fi
|
||||
else
|
||||
logger -p info -t upstart "PIDFILE ${PIDFILE} does not point to any prozess"
|
||||
logger -p info -t upstart "Cleanup ${PIDFILE} and start the prozess"
|
||||
rm ${PIDFILE}
|
||||
exit 0
|
||||
fi
|
Loading…
Reference in New Issue
Block a user