本文介绍了shell脚本来捕获进程ID,如果存在杀死它的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想这code和它不工作
I tried this code and it is not working
#!/bin/sh
#Find the Process ID for syncapp running instance
PID=`ps -ef | grep syncapp 'awk {print $2}'`
if [[ -z "$PID" ]] then
Kill -9 PID
fi
这是显示AWK附近一个错误。
It is showing a error near awk.
任何建议,请。
推荐答案
其实这样做是通过杀象下面参数的最简单的方法:
Actually the easiest way to do that would be to pass kill arguments like below:
ps -ef | grep your_process_name | grep -v grep | awk '{print $2}' | xargs kill
希望它帮助。
这篇关于shell脚本来捕获进程ID,如果存在杀死它的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!