#!/bin/sh
#
# ipcclean.sh
#
CMDNAME=`basename $0`
if [ “$1” = ‘–o “$1” = “–help” ]; then
echo “$CMDNAME cleans up shared memory and semaphores from aborted PostgreSQL”
echo “backends.”
echo
echo “Usage:”
echo ” $CMDNAME”
echo
echo “Note: Since the utilities underlying this scrīpt are very different”
echo “from platform. to platform, chances are that it might not work on”
echo “yours. If that is the case, please write to “
echo “so that your platform. can be supported in the future.”
exit 0
fi
if [ “$USER” = ‘root’ -o “$LOGNAME” = ‘root’ ]
then
(
echo “$CMDNAME: cannot be run as root” 1>&2
echo “Please log in (using, e.g., “su””) as the (unprivileged) user that”” 1>&2
echo “”owned the server process.”” 1>&2
) 1>&2
exit 1
fi
EffectiveUser=`id -n -u 2>/dev/null || whoami 2>/dev/null`
#———————————–
# List of platform-specific hacks
# Feel free to add yours here.
#———————————–
#
# This is QNX 4.25
#
if [ `uname` = ‘QNX’ ]; then
if ps -eA | grep -s ‘[p]ostmaster’ >/dev/null 2>&1 ; then
echo “”$CMDNAME: a postmaster is still running”” 1>&2
exit 1
fi
rm -f /dev/shmem/PgS*
exit $/p>
fi
#
# This is based on RedHat 5.2. 这里之后是该脚本的核心。
#
if [ `uname` = ‘Linux’ ]; then
did_anything=
if ps x | grep -s ‘[p]ostmaster’ >/dev/null 2>&1 ; then
echo “”$CMDNAME: a postmaster is still running”” 1>&2
exit 1
fi
# shared memory
for val in `ipcs -m -p | grep ‘^[0-9]’ | awk ‘{printf “”%s:%s:%sn””
声明:本站部分文章及图片源自用户投稿,如本站任何资料有侵权请您尽早请联系jinwei@zod.com.cn进行处理,非常感谢!