Update shutdown.sh

原脚本使用grep,但grep只能用于人工操作无法用于自动脚本,原因在于无论是否搜索到正确结果,都会返回该grep进程的ID号,这时候kill就报错了。
更改为pid文件方式也是业界较为稳妥的方式。
pull/35/head
sanxiHsu 3 years ago committed by GitHub
parent 82c7b59650
commit b7de791658
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -1,2 +1,36 @@
#!/bin/bash #!/bin/bash
kill -15 `ps -ef|grep kkFileView|awk 'NR==1{print $2}'` #
#
#############################
# Author: sanxi
# Version: 1.0
# Date: 2021/09/17
# Description: v1.0kkFileView
#############################
#
KKFILEVIEW_BIN_FOLDER=$(cd "$(dirname "$0")" || exit 1 ;pwd)
PID_FILE_NAME="kkFileView.pid"
PID_FILE="${KKFILEVIEW_BIN_FOLDER}/${PID_FILE_NAME}"
export KKFILEVIEW_BIN_FOLDER=$KKFILEVIEW_BIN_FOLDER
#
## pid
if [ ! -e "$PID_FILE" ]; then
echo "kkFileView.pid文件不存在"
exit 1
else
##
if [ -s "$PID_FILE" ]; then
# pidwhilePID_FILE
cat "${PID_FILE}" | while read PID;do
## 退
[ -z "$PID" ] && exit 2
echo "正在停止进程:${PID}..."
##
kill -15 "${PID}" && echo "进程:${PID}停止成功!"
done
# pid
cat /dev/null > "$PID_FILE"
else
echo "kkFileView进程尚未运行"
fi
fi

Loading…
Cancel
Save