shell 启动和停止脚本

时间:2022-12-21 08:10:26
启动脚本
start_kmeans_v3.sh
#!/bin/bash
#用于kmeans_data_v3_hadle启动
ps -ef | grep kmeans_data_v3_hadle.py > stop.txt
a2=$(awk 'END{print NR}' stop.txt)
rm -rf stop.txt
if [ ${a2} -gt 1 ]; then
    echo "已启动服务,请不要重复启动!"
else
    nohup python -u kmeans_data_v3_hadle.py > v3_hadlo.log &
fi
 
停止脚本
stop_kmeans_v3.sh
#!/bin/bash
#authon
#用于停掉kmeans_data_v3_hadle.py程序
ps -ef | grep kmeans_data_v3_hadle.py > stop.txt
a1=$(awk -F ' ' 'NR==1{print $2}' stop.txt)
kill -9 $a1
rm -rf stop.txt