kill process if really exists, otherwise remove the pid file
This commit is contained in:
parent
2023724370
commit
055ee8dd90
|
@ -116,13 +116,18 @@ pick_server() {
|
||||||
## Verify other evobackup process and kill if needed
|
## Verify other evobackup process and kill if needed
|
||||||
if [ -e "${PIDFILE}" ]; then
|
if [ -e "${PIDFILE}" ]; then
|
||||||
pid=$(cat "${PIDFILE}")
|
pid=$(cat "${PIDFILE}")
|
||||||
# Killing the childs of evobackup.
|
# Does process still exist ?
|
||||||
for ppid in $(pgrep -P "${pid}"); do
|
if kill -O ${pid} 2> /dev/null; then
|
||||||
kill -9 "${ppid}";
|
# Killing the childs of evobackup.
|
||||||
done
|
for ppid in $(pgrep -P "${pid}"); do
|
||||||
# Then kill the main PID.
|
kill -9 "${ppid}";
|
||||||
kill -9 "${pid}"
|
done
|
||||||
printf "%s is still running (PID %s). Process has been killed" "$0" "${pid}\n" >&2
|
# Then kill the main PID.
|
||||||
|
kill -9 "${pid}"
|
||||||
|
printf "%s is still running (PID %s). Process has been killed" "$0" "${pid}\n" >&2
|
||||||
|
else
|
||||||
|
rm -f ${PIDFILE}
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
echo "$$" > ${PIDFILE}
|
echo "$$" > ${PIDFILE}
|
||||||
# shellcheck disable=SC2064
|
# shellcheck disable=SC2064
|
||||||
|
|
Loading…
Reference in a new issue