Linux Bulk Kill Process

Source: Internet
Author: User
Tags flock

There is a server with a lot of send.php processes that need to kill

[Email protected]]#ps-aux | grep send.php

Warning:bad syntax, perhaps a bogus '-'? See/usr/share/doc/procps-3.2.8/faq

Root 8408 0.0 0.0 106096 1160? Ss 10:38 0:00/bin/sh-c Sleep 27; /usr/bin/flock-xn/tmp/smsinformuserqueue10.lock-c '/usr/local/php/bin/php/www/core/app/cron/sms/send.php Smsinformuserqueue >/dev/null 2>&1 '

Root 8471 0.0 0.0 106096 1160? Ss 10:38 0:00/bin/sh-c Sleep 27; /usr/bin/flock-xn/tmp/smsinformuserqueue9.lock-c '/usr/local/php/bin/php/www/core/app/cron/sms/send.php Smsinformuserqueue 9 >/dev/null 2>&1 '

Root 8548 0.0 0.0 106096 1156? Ss 10:38 0:00/bin/sh-c Sleep 27; /usr/bin/flock-xn/tmp/smsinformuserqueue3.lock-c '/usr/local/php/bin/php/www/core/app/cron/sms/send.php Smsinformuserqueue 3 >/dev/null 2>&1 '

Root 8745 0.0 0.0 106096 1160? Ss 10:38 0:00/bin/sh-c Sleep 26; /usr/bin/flock-xn/tmp/smsinformuserqueue.lock-c '/usr/local/php/bin/php/www/core/app/cron/sms/send.php Smsinformuserqueue 1 >/dev/null 2>&1 '

Root 8767 0.0 0.0 106096 1164? Ss 10:38 0:00/bin/sh-c Sleep 24; /usr/bin/flock-xn/tmp/smsinformuserqueue2.lock-c '/usr/local/php/bin/php/www/core/app/cron/sms/send.php Smsinformuserqueue 2 >/dev/null 2>&1 '

Root 9483 0.0 0.0 100892 532? S 10:38 0:00/usr/bin/flock-xn/tmp/smsinformuserqueue2.lock-c/USR/LOCAL/PHP/BIN/PHP/WWW/CORE/APP/CRON/SMS/SEND.P HP Smsinformuserqueue 2 >/dev/null 2>&1

Root 9484 0.0 0.0 106096 1144? S 10:38 0:00/bin/sh-c/usr/local/php/bin/php/www/core/app/cron/sms/send.php smsinformuserqueue 2 >/dev/null 2& Gt;&1

Root 9485 0.8 0.1 498880 30252? S 10:38 0:29/usr/local/php/bin/php/www/core/app/cron/sms/send.php Smsinformuserqueue 2

Root 9572 0.0 0.0 100892 536? S 10:38 0:00/usr/bin/flock-xn/tmp/smsinformuserqueue.lock-c/usr/local/php/bin/php/www/core/app/cron/sms/send.ph P Smsinformuserqueue 1 >/dev/null 2>&1

Root 9573 0.0 0.0 106096 1144? S 10:38 0:00/bin/sh-c

.....


If you follow the PID to kill each, the workload is too large

So I wrote a script kill.sh


#!/bin/bash


Processname= "send.php"

For PID in $ (PS aux |grep $processname |grep-v grep|awk ' {print $} '); Do

Kill-9 $pid

Done


Run directly, you can kill all the send.php processes.



This article is from the "Falling Star" blog, make sure to keep this source http://xiao987334176.blog.51cto.com/2202382/1769651

Linux Bulk Kill 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.