Ryan
Ryan

Reputation: 15270

How can I quickly kill all threads running a specific script?

I found a bunch of long running scripts (script.php) on a server and want to kill them all.

ps aux | grep script.php

user   6270  0.1  0.1 375580 50476 ?   Ss   Aug20   2:18 php /path/to/script.php
user   6290  0.1  0.1 375580 50476 ?   Ss   15:34   0:00 php /path/to/script.php
user   7439  0.1  0.1 375580 50476 ?   Ss   Aug18   2:05 php /path/to/script.php
user   8270  0.1  0.1 375580 50476 ?   Ss   Aug17   7:18 php /path/to/script.php
user   8548  0.1  0.1 375580 50476 ?   Ss   Aug15   0:15 php /path/to/script.php
user   8898  0.1  0.1 375580 50476 ?   Ss   Aug17   3:01 php /path/to/script.php
user   9875  0.1  0.1 375580 50476 ?   Ss   Aug18   2:18 php /path/to/script.php

I can kill them one at a time like so:

kill 6270

But how can I kill all of them at once?

Upvotes: 1

Views: 1080

Answers (2)

Quentin Geff
Quentin Geff

Reputation: 829

you can use the pkill command.

see http://en.wikipedia.org/wiki/Pkill and here http://www.unix.com/man-page/opensolaris/1/pkill/

Must be something like 'pkill -n script.php'

Upvotes: 2

Cyrus
Cyrus

Reputation: 88766

With Linux:

pkill -f "php /path/to/script.php"

Upvotes: 2

Related Questions