Sample Header Ad - 728x90

kill PID in the bash script

-1 votes
2 answers
274 views
I am using in my bash script the following syntax to kill the PID of the script - AmbariAgent.py kill $( ps -ef | grep AmbariAgent.py | grep -v grep | awk '{print $2 }' ) from ps -ef ps -ef | grep AmbariAgent.py | grep -v grep root 63769 1 0 12:39 pts/0 00:00:00 /usr/bin/python /usr/lib/python2.6/site-packages/ambari_agent/AmbariAgent.py start I am just asking if there are more elegant approach instead of the cli - kill $( ps -ef | grep AmbariAgent.py | grep -v grep | awk '{print $2 }' ) ? we try pkill AmbariAgent but PID still up # ps -ef | grep AmbariAgent root 3645 1 0 12:43 pts/0 00:00:00 /usr/bin/python /usr/lib/python2.6/site-packages/ambari_agent/AmbariAgent.py start root 31018 61002 0 13:02 pts/0 00:00:00 grep --color=auto AmbariAgent
Asked by yael (13936 rep)
Mar 25, 2020, 12:47 PM
Last activity: Mar 25, 2020, 04:45 PM