📄 mkillusers
字号:
#!/bin/sh# The contents of this file are subject to the MonetDB Public License# Version 1.1 (the "License"); you may not use this file except in# compliance with the License. You may obtain a copy of the License at# http://monetdb.cwi.nl/Legal/MonetDBLicense-1.1.html## Software distributed under the License is distributed on an "AS IS"# basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the# License for the specific language governing rights and limitations# under the License.## The Original Code is the MonetDB Database System.## The Initial Developer of the Original Code is CWI.# Portions created by CWI are Copyright (C) 1997-2007 CWI.# All Rights Reserved.for i in /sbin /usr/sbin /bin /usr/bin /usr/local/bin /usr/local/gnu/bin /cwi/bin ; do if [ -d "$i" ] ; then PATH="$i:$PATH" fidoneTHISPATH=${0%/*}THISFILE=${0##*/}CHILD=$$PARENT=""LOCKFILE="$$"while [ "${1#-}" != "$1" ] ; do if [ "$1" = -l ] ; then LOCKFILE="$2" ; shift ; shift elif [ "$1" != "${1#-l}" ] ; then LOCKFILE="${1#-l}" ; shift elif [ "$1" = -p ] ; then PARENT="$2" ; shift ; shift elif [ "$1" != "${1#-p}" ] ; then PARENT="${1#-p}" ; shift fidoneLOCKFILE=/tmp/.${0##*/}.$LOCKFILEfiles="`ls -d $* 2>/dev/null | egrep -v '\.KILLED\.(out|err)$'`"if [ ! "$files" ] ; then exit 0 ; fiwhile [ -f $LOCKFILE ] ; do sleep 9 ; donetouch $LOCKFILEfunction LOG1 () { prompt="\n# `date +%H:%M:%S` > " ; echo -en "$prompt$prompt$*$prompt\n\n" >&2 ; }function LOG2 () { LOG1 $* ; LOG1 $* >&2 ; }function LOG1x () { LOG1 $* ; "$@" >&2 ; }function LOG2x () { LOG2 $* ; "$@" ; }cpids=""if [ "$PARENT" ] ; then cpids="`ps -ef | egrep '^ *[a-zA-Z0-9_]+ +[0-9]+ +'"$PARENT"' ' | egrep -v '^ *[a-zA-Z0-9_]+ +'"$CHILD"' +[0-9]+ ' | sort -k 4.1 | awk '{printf "%s " , $2}' | perl -pe 's| *$||'`" if [ "$cpids" ] ; then# KIDS="`echo "($cpids)" | perl -pe 's/ /|/g'`"# gpids="`ps -ef | egrep '^ *[a-zA-Z0-9_]+ +[0-9]+ +'"$KIDS"' ' | egrep -v '^ *[a-zA-Z0-9_]+ +'"$CHILD"' +[0-9]+ ' | sort -k 4.1 | awk '{printf "%s " , $2}' | perl -pe 's| *$||'`"# if [ "$gpids" ] ; then# cpids="$cpids $gpids"# fi cpids="$cpids " fifiBINPATH="$THISPATH"if [ "$CLIENTS_PREFIX" ] ; then BINPATH="$BINPATH $CLIENTS_PREFIX/bin" ; fiif [ "$MONETDB_PREFIX" ] ; then BINPATH="$BINPATH $MONETDB_PREFIX/bin" ; fiif [ "$MONETDB4_PREFIX" ] ; then BINPATH="$BINPATH $MONETDB4_PREFIX/bin" ; fiif [ "$MONETDB5_PREFIX" ] ; then BINPATH="$BINPATH $MONETDB5_PREFIX/bin" ; fiif [ "$MONET5_PREFIX" ] ; then BINPATH="$BINPATH $MONET5_PREFIX/bin" ; fiif [ "$ACOI_PREFIX" ] ; then BINPATH="$BINPATH $ACOI_PREFIX/bin" ; fiif [ "$SQL_PREFIX" ] ; then BINPATH="$BINPATH $SQL_PREFIX/bin" ; fiif [ "$SQL5_PREFIX" ] ; then BINPATH="$BINPATH $SQL5_PREFIX/bin" ; fiif [ "$XML_PREFIX" ] ; then BINPATH="$BINPATH $XML_PREFIX/bin" ; fiif [ "$GIS_PREFIX" ] ; then BINPATH="$BINPATH $GIS_PREFIX/bin" ; fiif [ "$MISQ_PREFIX" ] ; then BINPATH="$BINPATH $MISQ_PREFIX/bin" ; fiif [ "$TIMES100_PREFIX" ] ; then BINPATH="$BINPATH $TIMES100_PREFIX/bin" ; fiif [ "$PLAYPEN_PREFIX" ] ; then BINPATH="$BINPATH $PLAYPEN_PREFIX/bin" ; fiif [ "$TEMPLATE_PREFIX" ] ; then BINPATH="$BINPATH $TEMPLATE_PREFIX/bin" ; fiif [ "$PATHFINDER_PREFIX" ] ; then BINPATH="$BINPATH $PATHFINDER_PREFIX/bin" ; fiif [ "$CLIENTS_BUILD" ] ; then BINPATH="$BINPATH $CLIENTS_BUILD/src/tools $CLIENTS_BUILD/src/tools/.libs" ; fiif [ "$MONETDB_BUILD" ] ; then BINPATH="$BINPATH $MONETDB_BUILD/src/tools $MONETDB_BUILD/src/tools/.libs" ; fiif [ "$MONETDB4_BUILD" ] ; then BINPATH="$BINPATH $MONETDB4_BUILD/src/tools $MONETDB4_BUILD/src/tools/.libs" ; fiif [ "$MONETDB5_BUILD" ] ; then BINPATH="$BINPATH $MONETDB5_BUILD/src/tools $MONETDB5_BUILD/src/tools/.libs" ; fiif [ "$MONET5_BUILD" ] ; then BINPATH="$BINPATH $MONET5_BUILD/src/tools $MONET5_BUILD/src/tools/.libs" ; fiif [ "$ACOI_BUILD" ] ; then BINPATH="$BINPATH $ACOI_BUILD/src/tools $ACOI_BUILD/src/tools/.libs" ; fiif [ "$SQL_BUILD" ] ; then BINPATH="$BINPATH $SQL_BUILD/src/tools $SQL_BUILD/src/tools/.libs" ; fiif [ "$SQL5_BUILD" ] ; then BINPATH="$BINPATH $SQL5_BUILD/src/tools $SQL5_BUILD/src/tools/.libs" ; fiif [ "$XML_BUILD" ] ; then BINPATH="$BINPATH $XML_BUILD/src/tools $XML_BUILD/src/tools/.libs" ; fiif [ "$GIS_BUILD" ] ; then BINPATH="$BINPATH $GIS_BUILD/src/tools $GIS_BUILD/src/tools/.libs" ; fiif [ "$MISQ_BUILD" ] ; then BINPATH="$BINPATH $MISQ_BUILD/src/tools $MISQ_BUILD/src/tools/.libs" ; fiif [ "$TIMES100_BUILD" ] ; then BINPATH="$BINPATH $TIMES100_BUILD/src/tools $TIMES100_BUILD/src/tools/.libs" ; fiif [ "$PLAYPEN_BUILD" ] ; then BINPATH="$BINPATH $PLAYPEN_BUILD/src/tools $PLAYPEN_BUILD/src/tools/.libs" ; fiif [ "$TEMPLATE_BUILD" ] ; then BINPATH="$BINPATH $TEMPLATE_BUILD/src/tools $TEMPLATE_BUILD/src/tools/.libs" ; fiif [ "$PATHFINDER_BUILD" ] ; then BINPATH="$BINPATH $PATHFINDER_BUILD/src/tools $PATHFINDER_BUILD/src/tools/.libs" ; fifor b in $BINPATH ; do files="$files `ls $b/* 2>/dev/null | egrep '/(mserver5|Mserver|MapiClient|MapiClient\.py|mclient|Mdiff|Mlog|Mtimeout|pf)$'`"donecase `uname` in Linux) pids1="`fuser $files | cut -d: -f2- | perl -pe 's|[a-z]||g'`" pids1="`echo "$pids1" | perl -pe 's| *'"$CHILD"'||g'`" if [ "$PARENT" ] ; then pids1="`echo "$pids1" | perl -pe 's| *'"$PARENT"'||g'`" fi pids1="$cpids$pids1" PS="ps -f $pids1" FUSER="fuser -v" ;; IRIX|IRIX64) pids0="`fuser -q $files`" pids0="`echo "$pids0" | perl -pe 's|,*'"$CHILD"'||g'`" if [ "$PARENT" ] ; then pids0="`echo "$pids0" | perl -pe 's|,*'"$PARENT"'||g'`" fi pids0="`echo $cpids | perl -pe 's| +|,|g'`${pids0#,}" pids1="`echo $pids0 | perl -pe 's|,| |g'`" PS="ps -fp $pids0" FUSER="fuser" ;; SunOS) pids1="`fuser $files 2>/dev/null`" pids1="`echo "$pids1" | perl -pe 's| *'"$CHILD"'||g'`" if [ "$PARENT" ] ; then pids1="`echo "$pids1" | perl -pe 's| *'"$PARENT"'||g'`" fi pids1="$cpids$pids1" pids0="`echo $pids1 | perl -pe 's| +|,|g'`" PS="ps -fp $pids0" FUSER="fuser" ;;# CYGWIN32_NT)# ;;esacif [ "$pids1" ] ; then LOG1 "BEGIN" pids2="(`echo $pids1 | perl -pe 's/ +/|/g'`)" echo PARENT=$PARENT >&2 echo CHILD=$CHILD >&2 echo files=$files >&2 echo cpids=$cpids >&2 echo pids1=$pids1 >&2 echo pids2=$pids2 >&2 LOG1x $PS LOG1x $FUSER $files #LOG1x fuser -k $files LOG1x kill $pids1 if [ "$cpids" ] ; then sleep 3 LOG1x kill $cpids fi sleep 4 if [ "`( ps -ef | egrep -w "$pids2" | egrep -v egrep ) 2>/dev/null`" ] ; then LOG1x kill -9 $pids1 fi LOG1 "END"firm -f $LOCKFILE
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -