Linux kill kills the specified process

Source: Internet
Author: User

One kills the specified process

Now know that a PHP thread is running and need to kill

Root 26278 1 0 2015? 00:00:31/usr/local/php/bin/php/var/www/html/redis/daemon/daemon_register.php
Root 26280 1 0 2015? 00:00:34/usr/local/php/bin/php/var/www/html/redis/daemon/daemon_register.php

PS-EF Query Run Process

[Email protected]$ ps-ef | grep php

Root 26278 1 0 2015? 00:00:31/usr/local/php/bin/php/var/www/html/redis/daemon/daemon_register.php
Root 26280 1 0 2015? 00:00:34/usr/local/php/bin/php/var/www/html/redis/daemon/daemon_register.php

Ps-ef Query and filter the process ID:

[Email protected]$ ps-ef | grep php

Root 26278 1 0 2015? 00:00:31/usr/local/php/bin/php/var/www/html/redis/daemon/daemon_register.php
Root 26280 1 0 2015? 00:00:34/usr/local/php/bin/php/var/www/html/redis/daemon/daemon_register.php

[Email protected]$ ps-ef | grep php | Grep-v grep | Cut-c 15-20

26280
26280

PS-EF queries and filters the process ID and kills the process:

[Email protected]$ ps-ef | grep php
Root 26278 1 0 2015? 00:00:31/usr/local/php/bin/php/var/www/html/redis/daemon/daemon_register.php (before killing process)
Root 26278 1 0 2015? 00:00:31/usr/local/php/bin/php/var/www/html/redis/daemon/daemon_register.php
[Email protected]$ ps-ef | grep Curl | Grep-v php | Cut-c 15-20
28367
[Email protected]$ ps-ef | grep php | Grep-v grep | Cut-c 15-20 | Xargs kill-9
[Email protected]$ ps-ef | grep php
Root 26278 1 0 2015? 00:00:31/usr/local/php/bin/php/var/www/html/redis/daemon/daemon_register.php (no this process after killing the process)

Or:

Kill-9 ' Ps-ef|grep "ProcessName" | Grep-v "grep" |awk ' {print $} '

Two kills batch process

For PID in $ (ps-ef | grep Curl | grep-v grep | cut-c 15-20); Do (get an array of process IDs and cycle through all processes)
Echo $pid
Kill-9 $pid
Done

Advised June: Kill is dangerous, use must be cautious.

Linux kill kills the specified process

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.