
저는 웹 스크립트를 통해 Linux 기반 OS(ubuntu, centos)에서 Counter-Strike 서버를 실행합니다. hlds_linux 프로세스에서 실행 중인 모든 프로세스를 찾아야 합니다(그는 hlds_run이라는 이름으로 다른 두 프로세스를 시작했습니다).
안전 모드가 꺼져 있고 shell_exec로 작업합니다. 나는 이 프로세스를 찾아서 그의 PID를 얻어서 그들을 죽일 수 있도록 해야 합니다. 도움을 주셔서 감사합니다. 저는 불가리아 출신입니다. 제 영어 실력이 부족해서 죄송합니다.
답변1
스위스 군용 전기톱인 Perl을 사용해 보세요. 다음은 포트 80을 열어 놓은 PID를 찾은 다음 모든 하위 항목을 나열하는 것입니다.
[me@lory ~]$ sudo netstat -apn|grep -w 80|grep LISTEN
tcp 0 0 :::80 :::* LISTEN 8308/httpd
[me@lory ~]$ ps -ef|perl -n -e '@j=split / */; print "@j" if ( @j[2]==8308) ; '
apache 9235 8308 0 Dec05 ? 00:01:49 /usr/sbin/httpd
apache 10040 8308 0 Dec08 ? 00:00:41 /usr/sbin/httpd
apache 10477 8308 0 Dec07 ? 00:01:13 /usr/sbin/httpd
apache 10478 8308 0 Dec07 ? 00:01:21 /usr/sbin/httpd
apache 10658 8308 0 Dec08 ? 00:00:29 /usr/sbin/httpd
apache 10662 8308 0 Dec08 ? 00:00:26 /usr/sbin/httpd
apache 10666 8308 0 Dec08 ? 00:00:28 /usr/sbin/httpd
apache 10668 8308 0 Dec08 ? 00:00:35 /usr/sbin/httpd
apache 12694 8308 0 Dec06 ? 00:01:39 /usr/sbin/httpd
apache 12695 8308 0 Dec06 ? 00:01:43 /usr/sbin/httpd
apache 12696 8308 0 Dec06 ? 00:01:39 /usr/sbin/httpd
apache 18671 8308 0 08:41 ? 00:00:18 /usr/sbin/httpd
apache 21585 8308 0 Dec08 ? 00:00:42 /usr/sbin/httpd
apache 22010 8308 0 Dec05 ? 00:01:33 /usr/sbin/httpd
apache 22011 8308 0 Dec05 ? 00:01:49 /usr/sbin/httpd
apache 22012 8308 0 Dec05 ? 00:01:36 /usr/sbin/httpd
PID만 원하는 경우:
[me@lory ~]$ ps -ef|perl -n -e '@j=split / */; print "@j[1]\n" if ( @j[2]==8308) ; '
9235
10040
10477
10478
10658
10662
10666
10668
12694
12695
12696
18671
21585
22010
22011
22012
답변2
당신이 사용할 수있는 pkill
(남성) 이름으로 모든 프로세스를 종료합니다.
답변3
이전 의견에서 말한 것처럼 ps auxf를 사용하면 다음과 같은 출력을 볼 수 있습니다.
root 13728 0.0 0.0 187448 6408 ? Ss 16:59 0:00 /usr/sbin/httpd2-prefork -f /etc/apache2/httpd.conf
wwwrun 13730 0.2 0.2 197868 17272 ? S 16:59 0:03 \_ /usr/sbin/httpd2-prefork -f /etc/apache2/httpd.conf
wwwrun 13732 0.3 0.2 197116 16548 ? S 16:59 0:04 \_ /usr/sbin/httpd2-prefork -f /etc/apache2/httpd.conf
wwwrun 13733 0.2 0.2 197888 17292 ? S 16:59 0:03 \_ /usr/sbin/httpd2-prefork -f /etc/apache2/httpd.conf
wwwrun 13734 1.0 0.2 198936 18204 ? S 16:59 0:15 \_ /usr/sbin/httpd2-prefork -f /etc/apache2/httpd.conf
wwwrun 13814 1.0 0.2 198164 17532 ? S 16:59 0:14 \_ /usr/sbin/httpd2-prefork -f /etc/apache2/httpd.conf
wwwrun 14205 0.2 0.2 198288 17668 ? S 17:03 0:02 \_ /usr/sbin/httpd2-prefork -f /etc/apache2/httpd.conf
wwwrun 14206 0.3 0.2 197892 17292 ? S 17:03 0:04 \_ /usr/sbin/httpd2-prefork -f /etc/apache2/httpd.conf
wwwrun 14207 0.2 0.2 198980 17984 ? S 17:03 0:02 \_ /usr/sbin/httpd2-prefork -f /etc/apache2/httpd.conf
wwwrun 14208 0.3 0.2 198188 17584 ? S 17:03 0:04 \_ /usr/sbin/httpd2-prefork -f /etc/apache2/httpd.conf
wwwrun 17125 0.2 0.2 197828 16872 ? S 17:21 0:00 \_ /usr/sbin/httpd2-prefork -f /etc/apache2/httpd.conf
이런 식으로 어떤 프로세스가 다른 프로세스를 생성했는지 확인할 수 있습니다.