반응형
kill `ps -ef | grep [process name] | grep -v grep | awk '{print $2}'`
ps -ef | grep test 현재 실행중인 test라는 이름을 포함한 프로세스를 모두 보여준다.
grep -v grep(패턴) : 지정된 패턴과 일치하는 항목을 제거, 1. ps -ef 2. grep 2개의 명령어 중 grep을 제거하기 위함이다.
awk {print $2} : awk는 입력 값을 공백 문자로 분리해서 필드로 처리, ps -ef 명령어를 통해 나온 결과에서 PID를 추출한다.
`명령어` : 치환 명령어
kill `ps -ef | grep [process name] | grep -v grep | awk '{print $2}'` 는 kill PID 형태로 실행된다.
반응형
'Develop > Linux' 카테고리의 다른 글
[Linux] 특정 날짜 기준으로 파일 삭제하기 (0) | 2022.12.08 |
---|---|
[Linux] npm install시 멈춤 현상 해결 방법 (0) | 2022.06.24 |
[Linux] npm install시 발생하는 exited with error code: 128 오류 (0) | 2022.06.22 |
[Linux] npm WARN using --force Recommended protections disabled. 오류 (0) | 2022.06.21 |
[Linux] cp: omitting directory 오류 해결 방법 (0) | 2022.03.21 |