
프로세스 ID를 찾고 Mac의 포트 8080에서 실행 중인 프로세스를 중지하려면 어떻게 해야 합니까?
우분투에서는 다음과 같이 작동합니다.
ps -aux
프로세스를 찾아 실행할 수 있습니다.
kill -9 pid
ps -aux
작동하지 않는 것 같습니다. Mac OS X Lion에서 어떻게 이 작업을 수행할 수 있습니까?
답변1
역사적인 이유로 인해 ps
의 옵션은 엉키고 일관성이 없습니다. OS X Lion에서는 다음 중 하나가 작동합니다.
ps -ax
ps -e
ps aux # this displays in a different format
테스트할 편리한 우분투 상자가 없지만매뉴얼 페이지, ps -aux
거기에서도 올바른 방법이 아닙니다.
Note that "ps -aux" is distinct from "ps aux". The POSIX and UNIX
standards require that "ps -aux" print all processes owned by a user
named "x", as well as printing all processes that would be selected by
the -a option. If the user named "x" does not exist, this ps may
interpret the command as "ps aux" instead and print a warning. This
behavior is intended to aid in transitioning old scripts and habits. It
is fragile, subject to change, and thus should not be relied upon.
답변2
문자열을 준수하는 모든 프로세스를 찾아 종료하려면 Mac OSX에서 다음을 사용할 수도 있습니다.
ps aux | grep <string> | awk '{print $1}' | <sudo> xargs kill -9
기본적으로 이것이 수행하는 작업은 시스템에서 현재 실행 중인 모든 프로세스와 일치하는 것을 찾아서(grep) AWK가 PID를 가져오는 것입니다. PID는 PS 명령에서 두 번째 열이고 마지막 열은 AWK에서 인수를 가져와서 종료합니다. 프로세스.
현재 사용자에게 프로세스를 종료할 수 있는 권한이 없고 시스템에 SUDO 액세스 권한이 있는 경우에만 SUDO를 사용하십시오.
답변3
Applications
-> Utilities
->Activity Monitor
답변4
macOS의 경우 최신 상태를 유지하려면 다음을 수행하세요.
ps -e | grep python | awk '{print "sudo kill -9", $1}' | sh
리눅스의 경우:
ps -ax | grep python | awk '{print "sudo kill -9", $1}' | sh