기본 콘텐츠로 건너뛰기

linux shell script : PID 확인

리눅스 ps -ef 로 프로세스 이름의 PID 찾기


ps -ef | grep -v "grep" | grep "원하는 프로세스 이름" | awk "{print $2}"


스크립트 - [ ` , "  , ' ] 에 주의 하시기 바랍니다

#!/bin/bash

echo "pid check start"
process_chk=`ps -ef | grep -v "grep" | grep "프로세스이름" | awk '{print $2}'`
if [ "$process_chk" != "" ]
then
        echo "프로세스 PID : $process_chk"
fi
echo "pid check end"


출처:

https://sonseungha.tistory.com/298

https://www.lesstif.com/lpt/id-20775506.html

https://seokhyun2.tistory.com/26

댓글