Score
0
Watch 91 Star 504 Fork 104

GVPhappyfish100 / FastDFSCGPL-3.0

Join us
Explore and code with more than 2 million developers,Free private repositories !:)
Sign up
FastDFS是一款轻量级的开源分布式文件系统,功能包括:文件存储、文件同步、文件上传、文件下载等,解决了文件大容量存储和高性能访问问题。特别适合以文件为载体的在线服务,如图片、视频、文档服务等等。FastDFS相关文章请搜索微信公众号:fastdfs spread retract

  • C 95.8%
  • PHP 2.3%
  • C++ 0.7%
  • Shell 0.7%
  • Makefile 0.4%
  • Other 0.1%
Clone or download
stop.sh 1.64 KB
Copy Edit Web IDE Raw Blame History
#!/bin/sh
if [ -z "$1" ]; then
/bin/echo "$0 <command line>"
exit 1
fi
if [ -f /bin/awk ]; then
AWK=/bin/awk
else
AWK=/usr/bin/awk
fi
if [ -f /bin/grep ]; then
GREP=/bin/grep
else
GREP=/usr/bin/grep
fi
if [ -f /bin/expr ]; then
EXPR=/bin/expr
else
EXPR=/usr/bin/expr
fi
if [ -f /bin/sed ]; then
SED=/bin/sed
else
SED=/usr/bin/sed
fi
program=`/bin/echo $1 | $AWK -F '/' '{print $NF;}'`
grep_cmd="$GREP -w $program"
list='2 3 4 5 6 7 8 9'
for i in $list; do
eval p='$'$i
if [ -z "$p" ]; then
break
fi
#first_ch=`$EXPR substr "$p" 1 1`
first_ch=`/bin/echo "$p" | $SED -e 's/\(.\).*/\1/'`
if [ "$first_ch" = "-" ]; then
p="'\\$p'"
fi
grep_cmd="$grep_cmd | $GREP -w $p"
done
cmd="/bin/ps auxww | $grep_cmd | $GREP -v grep | $GREP -v $0 | $AWK '{print \$2;}'"
pids=`/bin/sh -c "$cmd"`
if [ ! -z "$pids" ]; then
i=0
count=0
/bin/echo "stopping $program ..."
while [ 1 -eq 1 ]; do
new_pids=''
for pid in $pids; do
if [ $i -eq 0 ]; then
/bin/kill $pid
else
/bin/kill $pid >/dev/null 2>&1
fi
if [ $? -eq 0 ]; then
new_pids="$new_pids $pid"
fi
count=`$EXPR $count + 1`
done
if [ -z "$new_pids" ]; then
break
fi
pids="$new_pids"
/usr/bin/printf .
/bin/sleep 1
i=`$EXPR $i + 1`
done
fi
/bin/echo ""
cmd="/bin/ps auxww | $grep_cmd | $GREP -v grep | $GREP -v $0 | /usr/bin/wc -l"
count=`/bin/sh -c "$cmd"`
if [ $count -eq 0 ]; then
exit 0
else
cmd="/bin/ps auxww | $grep_cmd | $GREP -v grep | $GREP -v $0"
/bin/sh -c "$cmd"
/bin/echo "already running $program count: $count, stop fail!"
exit 16
fi

Comment ( 0 )

Sign in for post a comment

C
1
https://gitee.com/fastdfs100/fastdfs.git
git@gitee.com:fastdfs100/fastdfs.git
fastdfs100
fastdfs
FastDFS
master

Help Search