• 欢迎访问显哥博客,本网站纯属学习技术,绝无商业用途,欢迎小伙伴们共同学习!研究技术!QQ:52249909 加我QQ
  • 世界75亿人,这么小的概率,能认识你,是我一生的幸运,不妨加个QQ接触一下:52249909 加我QQ

shell脚本实现杀死进程并启动程序(重启程序)【显哥出品,必为精品】

技术栈 lixian 4年前 (2020-09-07) 1051次浏览 2个评论 扫描二维码
#!/bin/bash
#取jms进程号
Das_ID=$(ps -ef |grep "python3 ./jms start" |grep -v "grep"| awk '{print $2}')
Das_Id=$( ps -ef |grep "python3 ./jms start" |grep -v "grep"| awk '{print $2}' | wc -l)
if [ $Das_Id -eq 0 ];then
echo ""
echo "===当前系统没有运行jms==="
fi
if [ $Das_Id -ne 0 ];then
echo ""
echo "######打印jms进程号######"
echo "#                       #"
echo "#        $Das_ID           #"
echo "#                       #"
echo "#########################"
echo ""
echo "########关闭jms进程######"
kill -9 $Das_ID
echo "#                       #"
echo "#  进程 $Das_ID 关闭成功! #"
echo "#                       #"
echo "#########################"
fi


Das_Id_a=$( ps -ef |grep "python3 ./jms start" |grep -v "grep"| awk '{print $2}' | wc -l)
DATE=`date +%Y-%m-%d`
echo ""
echo "#########启动jms#########"
echo "#                       #"
if [ $Das_Id_a -eq 0 ];then
	cd /opt/jumpserver && nohup ./jms start >>/topsun/ztc/DAS/logs/das_${DATE}.log 2>&1 &
	echo "#       启动成功!      #"
fi
echo "#                       #"
echo "#########################"
echo ""

shell脚本实现杀死进程并启动程序(重启程序)【显哥出品,必为精品】

shell脚本实现杀死进程并启动程序(重启程序)【显哥出品,必为精品】


本站博主 , 版权所有丨如未注明 , 均为原创
转载请注明原文链接:shell脚本实现杀死进程并启动程序(重启程序)【显哥出品,必为精品】
喜欢 (2)

您必须 登录 才能发表评论!

(2)个小伙伴在吐槽
  1. I may need your help. I tried many ways but couldn't solve it, but after reading your article, I think you have a way to help me. I'm looking forward for your reply. Thanks.
    gate.io2023-06-08 10:33
  2. Reading your article has greatly helped me, and I agree with you. But I still have some questions. Can you help me? I will pay attention to your answer. thank you.