ℹ️ Skipped - page is already crawled
| Filter | Status | Condition | Details |
|---|---|---|---|
| HTTP status | PASS | download_http_code = 200 | HTTP 200 |
| Age cutoff | PASS | download_stamp > now() - 6 MONTH | 0.6 months ago |
| History drop | PASS | isNull(history_drop_reason) | No drop reason |
| Spam/ban | PASS | fh_dont_index != 1 AND ml_spam_score = 0 | ml_spam_score=0 |
| Canonical | PASS | meta_canonical IS NULL OR = '' OR = src_unparsed | Not set |
| Property | Value |
|---|---|
| URL | https://unix.stackexchange.com/questions/296086/how-to-kill-multiple-processes |
| Last Crawled | 2026-03-29 21:10:55 (18 days ago) |
| First Indexed | 2016-07-16 08:48:48 (9 years ago) |
| HTTP Status Code | 200 |
| Meta Title | ps - How to kill multiple processes - Unix & Linux Stack Exchange |
| Meta Description | null |
| Meta Canonical | null |
| Boilerpipe Text | This question shows research effort; it is useful and clear
31
Save this question.
Show activity on this post.
to find the PID of the process to kill use :
pgrep <process command>
I then use the kill command to kill the PID returned by
pgrep <process command>
kill <PID>
Can these commands be combined into one so can kill the PID or PID's returned by
pgrep <process command>
? Or is there a method kill multiple processes by command name ?
Something like :
kill(pgrep <name of process>)
terdon
♦
254k
69 gold badges
484 silver badges
722 bronze badges
asked
Jul 15, 2016 at 10:02
2
This answer is useful
37
Save this answer.
Show activity on this post.
You can use pkill:
pkill httpd
You may also want to use process substitution(although this isn't as clear):
kill $(pgrep command)
And you may want to use
xargs
:
pgrep command | xargs kill
slm
♦
381k
127 gold badges
794 silver badges
897 bronze badges
answered
Jul 15, 2016 at 10:11
5
This answer is useful
19
Save this answer.
Show activity on this post.
You can use
killall
as well, e.g.
killall firefox
to send
SIGTERM
to all
firefox
processes.
answered
Jul 15, 2016 at 10:27
3
This answer is useful
12
Save this answer.
Show activity on this post.
Yes, you can use a bash feature and looping over the output.
$ for proc in $(pgrep <process command>); do kill $proc; done
answered
Jul 15, 2016 at 10:12
2
This answer is useful
0
Save this answer.
Show activity on this post.
You can kill multiple process with array. In this case you can specify options as
$ip
,
$hostname
or something similar.
ip=your_ip_address; declare -a arr=$(ps aux|grep tail|grep $ip|awk '{print $2}'); for pid in ${arr[@]}; do kill -9 $pid; done;
answered
Jun 7, 2018 at 8:34
This answer is useful
0
Save this answer.
Show activity on this post.
When you are running scripts, especially in a stacking way, giving process name does not work for me. Thus I am using this simple command:
ps -eaf | grep -i script_hint (or whatever condition is) | awk '{print $2}' | xargs kill -15
answered
Apr 2, 2021 at 10:33
You must
log in
to answer this question.
Start asking to get answers
Find the answer to your question by asking.
Ask question
Explore related questions
See similar questions with these tags. |
| Markdown | # 
By clicking “Sign up”, you agree to our [terms of service](https://unix.stackexchange.com/legal/terms-of-service/public) and acknowledge you have read our [privacy policy](https://unix.stackexchange.com/legal/privacy-policy).
# OR
Already have an account? [Log in](https://unix.stackexchange.com/users/login)
[Skip to main content](https://unix.stackexchange.com/questions/296086/how-to-kill-multiple-processes#content)
#### Stack Exchange Network
Stack Exchange network consists of 183 Q\&A communities including [Stack Overflow](https://stackoverflow.com/), the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.
[Visit Stack Exchange](https://stackexchange.com/)
1. - [Tour Start here for a quick overview of the site](https://unix.stackexchange.com/tour)
- [Help Center Detailed answers to any questions you might have](https://unix.stackexchange.com/help)
- [Meta Discuss the workings and policies of this site](https://unix.meta.stackexchange.com/)
- [About Us Learn more about Stack Overflow the company, and our products](https://stackoverflow.co/)
2. ### [current community](https://unix.stackexchange.com/)
- [Unix & Linux](https://unix.stackexchange.com/)
[help](https://unix.stackexchange.com/help) [chat](https://chat.stackexchange.com/?tab=site&host=unix.stackexchange.com)
- [Unix & Linux Meta](https://unix.meta.stackexchange.com/)
### your communities
[Sign up](https://unix.stackexchange.com/users/signup?ssrc=site_switcher&returnurl=https%3A%2F%2Funix.stackexchange.com%2Fquestions%2F296086%2Fhow-to-kill-multiple-processes) or [log in](https://unix.stackexchange.com/users/login?ssrc=site_switcher&returnurl=https%3A%2F%2Funix.stackexchange.com%2Fquestions%2F296086%2Fhow-to-kill-multiple-processes) to customize your list.
### [more stack exchange communities](https://stackexchange.com/sites)
[company blog](https://stackoverflow.blog/)
3. [Log in](https://unix.stackexchange.com/users/login?ssrc=head&returnurl=https%3A%2F%2Funix.stackexchange.com%2Fquestions%2F296086%2Fhow-to-kill-multiple-processes)
4. [Sign up](https://unix.stackexchange.com/users/signup?ssrc=head&returnurl=https%3A%2F%2Funix.stackexchange.com%2Fquestions%2F296086%2Fhow-to-kill-multiple-processes)
[](https://unix.stackexchange.com/)
1. 1. [Home](https://unix.stackexchange.com/)
2. [Questions](https://unix.stackexchange.com/questions)
3. [Unanswered](https://unix.stackexchange.com/unanswered)
4. [AI Assist](https://stackoverflow.com/ai-assist)
5. [Tags](https://unix.stackexchange.com/tags)
6. [Chat](https://chat.stackexchange.com/)
7. [Users](https://unix.stackexchange.com/users)
8. [Companies](https://stackoverflow.com/jobs/companies?so_medium=unix&so_source=SiteNav)
2. Stack Internal
Stack Overflow for Teams is now called **Stack Internal**. Bring the best of human thought and AI automation together at your work.
[Try for free](https://stackoverflowteams.com/teams/create/free/?utm_medium=referral&utm_source=unix-community&utm_campaign=side-bar&utm_content=explore-teams) [Learn more](https://stackoverflow.co/internal/?utm_medium=referral&utm_source=unix-community&utm_campaign=side-bar&utm_content=explore-teams)
3. [Stack Internal]()
4. Bring the best of human thought and AI automation together at your work. [Learn more](https://stackoverflow.co/internal/?utm_medium=referral&utm_source=unix-community&utm_campaign=side-bar&utm_content=explore-teams-compact)
**Stack Internal**
Knowledge at work
Bring the best of human thought and AI automation together at your work.
[Explore Stack Internal](https://stackoverflow.co/internal/?utm_medium=referral&utm_source=unix-community&utm_campaign=side-bar&utm_content=explore-teams-compact-popover)
# [How to kill multiple processes](https://unix.stackexchange.com/questions/296086/how-to-kill-multiple-processes)
[Ask Question](https://unix.stackexchange.com/questions/ask)
Asked
9 years, 8 months ago
Modified [4 years, 11 months ago](https://unix.stackexchange.com/questions/296086/how-to-kill-multiple-processes?lastactivity "2021-04-02 10:33:38Z")
Viewed 90k times
This question shows research effort; it is useful and clear
31
Save this question.
Show activity on this post.
to find the PID of the process to kill use :
```
pgrep <process command>
```
I then use the kill command to kill the PID returned by `pgrep <process command>`
```
kill <PID>
```
Can these commands be combined into one so can kill the PID or PID's returned by `pgrep <process command>` ? Or is there a method kill multiple processes by command name ?
Something like : `kill(pgrep <name of process>)`
- [kill](https://unix.stackexchange.com/questions/tagged/kill "show questions tagged 'kill'")
- [ps](https://unix.stackexchange.com/questions/tagged/ps "show questions tagged 'ps'")
- [process-management](https://unix.stackexchange.com/questions/tagged/process-management "show questions tagged 'process-management'")
[Share](https://unix.stackexchange.com/q/296086 "Short permalink to this question")
Share a link to this question
Copy link
[CC BY-SA 3.0](https://creativecommons.org/licenses/by-sa/3.0/ "The current license for this post: CC BY-SA 3.0")
[Improve this question](https://unix.stackexchange.com/posts/296086/edit)
Follow
Follow this question to receive notifications
[edited Jul 15, 2016 at 10:16](https://unix.stackexchange.com/posts/296086/revisions "show all edits to this post")
[](https://unix.stackexchange.com/users/22222/terdon)
[terdon](https://unix.stackexchange.com/users/22222/terdon)♦
254k6969 gold badges484484 silver badges722722 bronze badges
asked Jul 15, 2016 at 10:02
[](https://unix.stackexchange.com/users/65628/blue-sky)
[blue-sky](https://unix.stackexchange.com/users/65628/blue-sky)
49011 gold badge66 silver badges1414 bronze badges
2
- 3
Did you try `pkill`? Alternatively, you may want to use `xargs`.
MatthewRock
– [MatthewRock](https://unix.stackexchange.com/users/129998/matthewrock "7,244 reputation")
2016-07-15 10:07:40 +00:00
[Commented Jul 15, 2016 at 10:07](https://unix.stackexchange.com/questions/296086/how-to-kill-multiple-processes#comment519739_296086)
- 1
Note that man pages are also good for stuff like this. Often they not only tell you how to use the command, they also tell you about related commands. In this case, the `pgrep` man page mentions `pkill` all over the place (as the 2 commands come from the same package).
phemmer
– [phemmer](https://unix.stackexchange.com/users/4358/phemmer "74,101 reputation")
2016-07-15 12:37:34 +00:00
[Commented Jul 15, 2016 at 12:37](https://unix.stackexchange.com/questions/296086/how-to-kill-multiple-processes#comment519819_296086)
[Add a comment](https://unix.stackexchange.com/questions/296086/how-to-kill-multiple-processes "Use comments to ask for more information or suggest improvements. Avoid answering questions in comments.") \|
## 5 Answers 5
Sorted by:
[Reset to default](https://unix.stackexchange.com/questions/296086/how-to-kill-multiple-processes?answertab=scoredesc#tab-top)
This answer is useful
37
Save this answer.
Show activity on this post.
You can use pkill:
```
pkill httpd
```
You may also want to use process substitution(although this isn't as clear):
```
kill $(pgrep command)
```
And you may want to use `xargs`:
```
pgrep command | xargs kill
```
[Share](https://unix.stackexchange.com/a/296088 "Short permalink to this answer")
Share a link to this answer
Copy link
[CC BY-SA 3.0](https://creativecommons.org/licenses/by-sa/3.0/ "The current license for this post: CC BY-SA 3.0")
[Improve this answer](https://unix.stackexchange.com/posts/296088/edit)
Follow
Follow this answer to receive notifications
[edited Nov 8, 2016 at 0:38](https://unix.stackexchange.com/posts/296088/revisions "show all edits to this post")
[](https://unix.stackexchange.com/users/7453/slm)
[slm](https://unix.stackexchange.com/users/7453/slm)♦
381k127127 gold badges794794 silver badges897897 bronze badges
answered Jul 15, 2016 at 10:11
[](https://unix.stackexchange.com/users/129998/matthewrock)
[MatthewRock](https://unix.stackexchange.com/users/129998/matthewrock)
7,24477 gold badges3535 silver badges5555 bronze badges
5
- 4
I did a similar thing in an answer and it was pointed out to me that I introduced a race condition. The process IDs may be invalidated inbetween the calls to `pgrep` and `kill`. Just use `pkill`.
Kusalananda
– [Kusalananda](https://unix.stackexchange.com/users/116858/kusalananda "357,982 reputation") ♦
2016-07-15 10:37:08 +00:00
[Commented Jul 15, 2016 at 10:37](https://unix.stackexchange.com/questions/296086/how-to-kill-multiple-processes#comment519755_296088)
- 3
@Kusalananda the same thing can also happen between `pkill` getting the process list and actually sending the signal, it's just harder to see in that case.
hobbs
– [hobbs](https://unix.stackexchange.com/users/1215/hobbs "1,152 reputation")
2016-07-15 19:33:58 +00:00
[Commented Jul 15, 2016 at 19:33](https://unix.stackexchange.com/questions/296086/how-to-kill-multiple-processes#comment519993_296088)
- 1
I was going to try to compose an answer that looped something like `kill $(ps|head -1)` to avoid the race condition ... but there really isn't a way to avoid it. The process could die at any point in the pipeline.
Ross Presser
– [Ross Presser](https://unix.stackexchange.com/users/124478/ross-presser "143 reputation")
2016-07-15 23:01:02 +00:00
[Commented Jul 15, 2016 at 23:01](https://unix.stackexchange.com/questions/296086/how-to-kill-multiple-processes#comment520052_296088)
- Just be careful with pkill because some programs may have more than one instance running and you might not want to kill all of them. Running pgrep first will help as long as another one doesn't start between the time you run pgrep and pkill (race).
Joe
– [Joe](https://unix.stackexchange.com/users/10292/joe "1,388 reputation")
2016-07-17 08:11:00 +00:00
[Commented Jul 17, 2016 at 8:11](https://unix.stackexchange.com/questions/296086/how-to-kill-multiple-processes#comment520442_296088)
- 1
Even a C program can't avoid the race condition, the window will just be smaller. The only way to do it truly atomically would be to add a system call that kills processes by name. But process IDs generally won't be reused very quickly, so the danger is virtually nonexistent.
Barmar
– [Barmar](https://unix.stackexchange.com/users/61098/barmar "10,591 reputation")
2016-07-20 17:35:43 +00:00
[Commented Jul 20, 2016 at 17:35](https://unix.stackexchange.com/questions/296086/how-to-kill-multiple-processes#comment521926_296088)
[Add a comment](https://unix.stackexchange.com/questions/296086/how-to-kill-multiple-processes "Use comments to ask for more information or suggest improvements. Avoid comments like “+1” or “thanks”.") \|
This answer is useful
19
Save this answer.
Show activity on this post.
You can use `killall` as well, e.g.
```
killall firefox
```
to send `SIGTERM` to all `firefox` processes.
[Share](https://unix.stackexchange.com/a/296092 "Short permalink to this answer")
Share a link to this answer
Copy link
[CC BY-SA 3.0](https://creativecommons.org/licenses/by-sa/3.0/ "The current license for this post: CC BY-SA 3.0")
[Improve this answer](https://unix.stackexchange.com/posts/296092/edit)
Follow
Follow this answer to receive notifications
answered Jul 15, 2016 at 10:27
[](https://unix.stackexchange.com/users/103151/byte-commander)
[Byte Commander](https://unix.stackexchange.com/users/103151/byte-commander)
1,8611414 silver badges2828 bronze badges
3
- 8
Note that `killall` has different meanings on different unix systems - if you're on a non-Linux system make sure to check the documentation.
Random832
– [Random832](https://unix.stackexchange.com/users/6290/random832 "11,281 reputation")
2016-07-15 14:54:18 +00:00
[Commented Jul 15, 2016 at 14:54](https://unix.stackexchange.com/questions/296086/how-to-kill-multiple-processes#comment519881_296092)
- `killall -KILL firefox` can feel *sooo* rewarding.
pipe
– [pipe](https://unix.stackexchange.com/users/145426/pipe "892 reputation")
2016-07-16 10:20:48 +00:00
[Commented Jul 16, 2016 at 10:20](https://unix.stackexchange.com/questions/296086/how-to-kill-multiple-processes#comment520176_296092)
- The non-portability of `killall` is why I never use it. Running `killall` on a solaris box for example is disastrous.
phemmer
– [phemmer](https://unix.stackexchange.com/users/4358/phemmer "74,101 reputation")
2016-07-21 03:10:14 +00:00
[Commented Jul 21, 2016 at 3:10](https://unix.stackexchange.com/questions/296086/how-to-kill-multiple-processes#comment522104_296092)
[Add a comment](https://unix.stackexchange.com/questions/296086/how-to-kill-multiple-processes "Use comments to ask for more information or suggest improvements. Avoid comments like “+1” or “thanks”.") \|
This answer is useful
12
Save this answer.
Show activity on this post.
Yes, you can use a bash feature and looping over the output.
```
$ for proc in $(pgrep <process command>); do kill $proc; done
```
[Share](https://unix.stackexchange.com/a/296089 "Short permalink to this answer")
Share a link to this answer
Copy link
[CC BY-SA 3.0](https://creativecommons.org/licenses/by-sa/3.0/ "The current license for this post: CC BY-SA 3.0")
[Improve this answer](https://unix.stackexchange.com/posts/296089/edit)
Follow
Follow this answer to receive notifications
answered Jul 15, 2016 at 10:12
[](https://unix.stackexchange.com/users/1186/lcipriani)
[lcipriani](https://unix.stackexchange.com/users/1186/lcipriani)
74266 silver badges88 bronze badges
2
- 1
I get `kill <no>:failed: operation not permitted`
Timo
– [Timo](https://unix.stackexchange.com/users/72988/timo "348 reputation")
2017-11-18 21:55:36 +00:00
[Commented Nov 18, 2017 at 21:55](https://unix.stackexchange.com/questions/296086/how-to-kill-multiple-processes#comment725280_296089)
- Probably you do not have the right permissions or the process does not exists anymore, please refer to: [superuser.com/questions/1175485/…](https://superuser.com/questions/1175485/why-operation-not-permitted-when-kill-a-nonexistent-process-and-why-need-to-be-k "why operation not permitted when kill a nonexistent process and why need to be k")
lcipriani
– [lcipriani](https://unix.stackexchange.com/users/1186/lcipriani "742 reputation")
2017-12-11 13:23:19 +00:00
[Commented Dec 11, 2017 at 13:23](https://unix.stackexchange.com/questions/296086/how-to-kill-multiple-processes#comment734855_296089)
[Add a comment](https://unix.stackexchange.com/questions/296086/how-to-kill-multiple-processes "Use comments to ask for more information or suggest improvements. Avoid comments like “+1” or “thanks”.") \|
This answer is useful
0
Save this answer.
Show activity on this post.
You can kill multiple process with array. In this case you can specify options as `$ip`, `$hostname` or something similar.
```
ip=your_ip_address; declare -a arr=$(ps aux|grep tail|grep $ip|awk '{print $2}'); for pid in ${arr[@]}; do kill -9 $pid; done;
```
[Share](https://unix.stackexchange.com/a/448363 "Short permalink to this answer")
Share a link to this answer
Copy link
[CC BY-SA 4.0](https://creativecommons.org/licenses/by-sa/4.0/ "The current license for this post: CC BY-SA 4.0")
[Improve this answer](https://unix.stackexchange.com/posts/448363/edit)
Follow
Follow this answer to receive notifications
[edited Jun 7, 2018 at 10:09](https://unix.stackexchange.com/posts/448363/revisions "show all edits to this post")
[](https://unix.stackexchange.com/users/195932/kevin-lemaire)
[Kevin Lemaire](https://unix.stackexchange.com/users/195932/kevin-lemaire)
1,72911 gold badge1414 silver badges2828 bronze badges
answered Jun 7, 2018 at 8:34
[](https://unix.stackexchange.com/users/237730/vladyslav-greyswandir)
[Vladyslav Greyswandir](https://unix.stackexchange.com/users/237730/vladyslav-greyswandir)
2111 silver badge55 bronze badges
[Add a comment](https://unix.stackexchange.com/questions/296086/how-to-kill-multiple-processes "Use comments to ask for more information or suggest improvements. Avoid comments like “+1” or “thanks”.") \|
This answer is useful
0
Save this answer.
Show activity on this post.
When you are running scripts, especially in a stacking way, giving process name does not work for me. Thus I am using this simple command:
```
ps -eaf | grep -i script_hint (or whatever condition is) | awk '{print $2}' | xargs kill -15
```
[Share](https://unix.stackexchange.com/a/643210 "Short permalink to this answer")
Share a link to this answer
Copy link
[CC BY-SA 4.0](https://creativecommons.org/licenses/by-sa/4.0/ "The current license for this post: CC BY-SA 4.0")
[Improve this answer](https://unix.stackexchange.com/posts/643210/edit)
Follow
Follow this answer to receive notifications
answered Apr 2, 2021 at 10:33
[](https://unix.stackexchange.com/users/421849/acfglmrsx)
[acfglmrsx](https://unix.stackexchange.com/users/421849/acfglmrsx)
3366 bronze badges
[Add a comment](https://unix.stackexchange.com/questions/296086/how-to-kill-multiple-processes "Use comments to ask for more information or suggest improvements. Avoid comments like “+1” or “thanks”.") \|
## You must [log in](https://unix.stackexchange.com/users/login?ssrc=question_page&returnurl=https%3A%2F%2Funix.stackexchange.com%2Fquestions%2F296086) to answer this question.
Start asking to get answers
Find the answer to your question by asking.
[Ask question](https://unix.stackexchange.com/questions/ask)
Explore related questions
- [kill](https://unix.stackexchange.com/questions/tagged/kill "show questions tagged 'kill'")
- [ps](https://unix.stackexchange.com/questions/tagged/ps "show questions tagged 'ps'")
- [process-management](https://unix.stackexchange.com/questions/tagged/process-management "show questions tagged 'process-management'")
See similar questions with these tags.
- The Overflow Blog
- [Prevent agentic identity theft](https://stackoverflow.blog/2026/03/27/prevent-agentic-identity-theft/?cb=1)
- [Building shared coding guidelines for AI (and people too)](https://stackoverflow.blog/2026/03/26/coding-guidelines-for-ai-agents-and-people-too/?cb=1)
#### Related
[1](https://unix.stackexchange.com/questions/213159/kill-processes-in-one-line-with-kill-awk-ps-and-grep?rq=1 "Question score (upvotes - downvotes)")
[kill processes in one line with kill, awk, ps, and grep](https://unix.stackexchange.com/questions/213159/kill-processes-in-one-line-with-kill-awk-ps-and-grep?rq=1)
[5](https://unix.stackexchange.com/questions/283564/how-do-i-kill-all-processes-except-pid-1?rq=1 "Question score (upvotes - downvotes)")
[How do I kill all processes except PID 1?](https://unix.stackexchange.com/questions/283564/how-do-i-kill-all-processes-except-pid-1?rq=1)
[2](https://unix.stackexchange.com/questions/318133/pipe-all-the-suspended-processes-to-kill?rq=1 "Question score (upvotes - downvotes)")
[Pipe all the suspended processes to kill](https://unix.stackexchange.com/questions/318133/pipe-all-the-suspended-processes-to-kill?rq=1)
[1](https://unix.stackexchange.com/questions/381887/filter-out-and-kill-non-docker-processes?rq=1 "Question score (upvotes - downvotes)")
[Filter out and kill non-docker processes](https://unix.stackexchange.com/questions/381887/filter-out-and-kill-non-docker-processes?rq=1)
[2](https://unix.stackexchange.com/questions/493203/how-to-kill-and-rerun-process-in-one-command-in-linux?rq=1 "Question score (upvotes - downvotes)")
[How to kill and rerun process in one command in Linux](https://unix.stackexchange.com/questions/493203/how-to-kill-and-rerun-process-in-one-command-in-linux?rq=1)
[6](https://unix.stackexchange.com/questions/644626/is-there-a-clean-way-to-sudo-pkill-processes-without-including-the-sudo-proc?rq=1 "Question score (upvotes - downvotes)")
[Is there a clean way to \`sudo pkill\` processes without including the \`sudo\` process?](https://unix.stackexchange.com/questions/644626/is-there-a-clean-way-to-sudo-pkill-processes-without-including-the-sudo-proc?rq=1)
[1](https://unix.stackexchange.com/questions/767405/start-multiple-terminal-windows-in-a-process-group-so-that-remaining-processes?rq=1 "Question score (upvotes - downvotes)")
[start multiple terminal windows in a "process group" so that remaining processes can be killed, if any one of the processes terminates](https://unix.stackexchange.com/questions/767405/start-multiple-terminal-windows-in-a-process-group-so-that-remaining-processes?rq=1)
#### [Hot Network Questions](https://stackexchange.com/questions?tab=hot)
- [D'Alembert's Principle and its relation to the derivation of Lagrangian mechanics](https://physics.stackexchange.com/questions/870635/dalemberts-principle-and-its-relation-to-the-derivation-of-lagrangian-mechanic)
- [Why is ngspice giving me extremely small voltages?](https://electronics.stackexchange.com/questions/767461/why-is-ngspice-giving-me-extremely-small-voltages)
- [Two hunters and 1 rabbit in bushes in a circle](https://puzzling.stackexchange.com/questions/137511/two-hunters-and-1-rabbit-in-bushes-in-a-circle)
- [When to use fateor and confiteor?](https://latin.stackexchange.com/questions/27144/when-to-use-fateor-and-confiteor)
- [Why was Cameron able to destroy Cromartie with a shotgun?](https://scifi.stackexchange.com/questions/303853/why-was-cameron-able-to-destroy-cromartie-with-a-shotgun)
- [Why does certain modern symphony music sound like movie scores to me?](https://music.stackexchange.com/questions/143421/why-does-certain-modern-symphony-music-sound-like-movie-scores-to-me)
- [Could we spot an alien ship entering the Solar System?](https://worldbuilding.stackexchange.com/questions/273008/could-we-spot-an-alien-ship-entering-the-solar-system)
- [How to decide if an interaction exists: graphically/interaction terms/contrasts of slopes](https://stats.stackexchange.com/questions/675350/how-to-decide-if-an-interaction-exists-graphically-interaction-terms-contrasts)
- [Does the effect of a Potion of Growth stack with the Enlarge spell?](https://rpg.stackexchange.com/questions/219017/does-the-effect-of-a-potion-of-growth-stack-with-the-enlarge-spell)
- [How could a low-gravity world keep its atmosphere?](https://worldbuilding.stackexchange.com/questions/273021/how-could-a-low-gravity-world-keep-its-atmosphere)
- [Should I avoid a Dunn's test if my groups have different variability?](https://stats.stackexchange.com/questions/675352/should-i-avoid-a-dunns-test-if-my-groups-have-different-variability)
- [What's the usefulness of importing cars in GTA San Andreas?](https://gaming.stackexchange.com/questions/418267/whats-the-usefulness-of-importing-cars-in-gta-san-andreas)
- [Are Indians taught to idolize the West?](https://politics.stackexchange.com/questions/94437/are-indians-taught-to-idolize-the-west)
- [Does UEFI support at least 1 EFI partition per drive?](https://superuser.com/questions/1936193/does-uefi-support-at-least-1-efi-partition-per-drive)
- [What are these straps on these common pressure suits?](https://space.stackexchange.com/questions/70377/what-are-these-straps-on-these-common-pressure-suits)
- [Surviving Letters](https://puzzling.stackexchange.com/questions/137517/surviving-letters)
- [What does "tip up" mean? \[The Goldfinch\]](https://ell.stackexchange.com/questions/374429/what-does-tip-up-mean-the-goldfinch)
- [If Riri Williams is already in her Ironheart suit, then who is the "her" Okoye is referring to?](https://scifi.stackexchange.com/questions/303860/if-riri-williams-is-already-in-her-ironheart-suit-then-who-is-the-her-okoye-i)
- [What is a better approach to plot the double path style as a subpath?](https://tex.stackexchange.com/questions/761358/what-is-a-better-approach-to-plot-the-double-path-style-as-a-subpath)
- [Mesh not following curve](https://blender.stackexchange.com/questions/345930/mesh-not-following-curve)
- [Get index of aperiodic number](https://codegolf.stackexchange.com/questions/287699/get-index-of-aperiodic-number)
- [In an Ansible INI file, does a blank line break a group?](https://unix.stackexchange.com/questions/805183/in-an-ansible-ini-file-does-a-blank-line-break-a-group)
- [A political campaign texted me after I sent them a STOP message, does this violate the Telephone Consumer Protection Act?](https://law.stackexchange.com/questions/114473/a-political-campaign-texted-me-after-i-sent-them-a-stop-message-does-this-viola)
- [Different types of lines in tree diagram](https://tex.stackexchange.com/questions/761312/different-types-of-lines-in-tree-diagram)
[Question feed](https://unix.stackexchange.com/feeds/question/296086 "Feed of this question and its answers")
# Subscribe to RSS
Question feed
To subscribe to this RSS feed, copy and paste this URL into your RSS reader.

# Why are you flagging this comment?
It contains harassment, bigotry or abuse.
This comment attacks a person or group. Learn more in our [Abusive behavior policy](https://unix.stackexchange.com/conduct/abusive-behavior).
It's unfriendly or unkind.
This comment is rude or condescending. Learn more in our [Code of Conduct](https://unix.stackexchange.com/conduct/abusive-behavior).
Not needed.
This comment is not relevant to the post.
```
```
Enter at least 6 characters
Something else.
A problem not listed above. Try to be as specific as possible.
```
```
Enter at least 6 characters
Flag comment
Cancel
You have 0 flags left today
# 
# Hang on, you can't upvote just yet.
You'll need to complete a few actions and gain 15 reputation points before being able to upvote. **Upvoting** indicates when questions and answers are useful. [What's reputation and how do I get it?](https://stackoverflow.com/help/whats-reputation)
Instead, you can save this post to reference later.
Save this post for later
Not now
##### [Unix & Linux](https://unix.stackexchange.com/)
- [Tour](https://unix.stackexchange.com/tour)
- [Help](https://unix.stackexchange.com/help)
- [Chat](https://chat.stackexchange.com/?tab=site&host=unix.stackexchange.com)
- [Contact](https://unix.stackexchange.com/contact)
- [Feedback](https://unix.meta.stackexchange.com/)
##### [Company](https://stackoverflow.co/)
- [Stack Overflow](https://stackoverflow.com/)
- [Stack Internal](https://stackoverflow.co/internal/)
- [Stack Data Licensing](https://stackoverflow.co/data-licensing/)
- [Stack Ads](https://stackoverflow.co/advertising/)
- [About](https://stackoverflow.co/)
- [Press](https://stackoverflow.co/company/press/)
- [Legal](https://stackoverflow.com/legal)
- [Privacy Policy](https://stackoverflow.com/legal/privacy-policy)
- [Terms of Service](https://stackoverflow.com/legal/terms-of-service/public)
- Cookie Settings
- [Cookie Policy](https://policies.stackoverflow.co/stack-overflow/cookie-policy)
##### [Stack Exchange Network](https://stackexchange.com/)
- [Technology](https://stackexchange.com/sites#technology)
- [Culture & recreation](https://stackexchange.com/sites#culturerecreation)
- [Life & arts](https://stackexchange.com/sites#lifearts)
- [Science](https://stackexchange.com/sites#science)
- [Professional](https://stackexchange.com/sites#professional)
- [Business](https://stackexchange.com/sites#business)
- [API](https://api.stackexchange.com/)
- [Data](https://data.stackexchange.com/)
- [Blog](https://stackoverflow.blog/?blb=1)
- [Facebook](https://www.facebook.com/officialstackoverflow/)
- [Twitter](https://twitter.com/stackoverflow)
- [LinkedIn](https://linkedin.com/company/stack-overflow)
- [Instagram](https://www.instagram.com/thestackoverflow)
Site design / logo © 2026 Stack Exchange Inc; user contributions licensed under [CC BY-SA](https://stackoverflow.com/help/licensing) . rev 2026.3.27.41560
Linux is a registered trademark of Linus Torvalds. UNIX is a registered trademark of The Open Group.
This site is not affiliated with Linus Torvalds or The Open Group in any way. |
| Readable Markdown | This question shows research effort; it is useful and clear
31
Save this question.
Show activity on this post.
to find the PID of the process to kill use :
```
pgrep <process command>
```
I then use the kill command to kill the PID returned by `pgrep <process command>`
```
kill <PID>
```
Can these commands be combined into one so can kill the PID or PID's returned by `pgrep <process command>` ? Or is there a method kill multiple processes by command name ?
Something like : `kill(pgrep <name of process>)`
[](https://unix.stackexchange.com/users/22222/terdon)
[terdon](https://unix.stackexchange.com/users/22222/terdon)♦
254k69 gold badges484 silver badges722 bronze badges
asked Jul 15, 2016 at 10:02
[](https://unix.stackexchange.com/users/65628/blue-sky)
2
This answer is useful
37
Save this answer.
Show activity on this post.
You can use pkill:
```
pkill httpd
```
You may also want to use process substitution(although this isn't as clear):
```
kill $(pgrep command)
```
And you may want to use `xargs`:
```
pgrep command | xargs kill
```
[](https://unix.stackexchange.com/users/7453/slm)
[slm](https://unix.stackexchange.com/users/7453/slm)♦
381k127 gold badges794 silver badges897 bronze badges
answered Jul 15, 2016 at 10:11
[](https://unix.stackexchange.com/users/129998/matthewrock)
5
This answer is useful
19
Save this answer.
Show activity on this post.
You can use `killall` as well, e.g.
```
killall firefox
```
to send `SIGTERM` to all `firefox` processes.
answered Jul 15, 2016 at 10:27
[](https://unix.stackexchange.com/users/103151/byte-commander)
3
This answer is useful
12
Save this answer.
Show activity on this post.
Yes, you can use a bash feature and looping over the output.
```
$ for proc in $(pgrep <process command>); do kill $proc; done
```
answered Jul 15, 2016 at 10:12
[](https://unix.stackexchange.com/users/1186/lcipriani)
2
This answer is useful
0
Save this answer.
Show activity on this post.
You can kill multiple process with array. In this case you can specify options as `$ip`, `$hostname` or something similar.
```
ip=your_ip_address; declare -a arr=$(ps aux|grep tail|grep $ip|awk '{print $2}'); for pid in ${arr[@]}; do kill -9 $pid; done;
```
[](https://unix.stackexchange.com/users/195932/kevin-lemaire)
answered Jun 7, 2018 at 8:34
[](https://unix.stackexchange.com/users/237730/vladyslav-greyswandir)
This answer is useful
0
Save this answer.
Show activity on this post.
When you are running scripts, especially in a stacking way, giving process name does not work for me. Thus I am using this simple command:
```
ps -eaf | grep -i script_hint (or whatever condition is) | awk '{print $2}' | xargs kill -15
```
answered Apr 2, 2021 at 10:33
[](https://unix.stackexchange.com/users/421849/acfglmrsx)
## You must [log in](https://unix.stackexchange.com/users/login?ssrc=question_page&returnurl=https%3A%2F%2Funix.stackexchange.com%2Fquestions%2F296086) to answer this question.
Start asking to get answers
Find the answer to your question by asking.
[Ask question](https://unix.stackexchange.com/questions/ask)
Explore related questions
See similar questions with these tags. |
| Shard | 18 (laksa) |
| Root Hash | 8045678284012640218 |
| Unparsed URL | com,stackexchange!unix,/questions/296086/how-to-kill-multiple-processes s443 |