How to kill all processes with the same name?

6,262

You can use the pkill command.

pkill -u user_1 myapp

Note that myapp2 won't be killed as it has a different name.

Share:
6,262

Related videos on Youtube

Omar Malas
Author by

Omar Malas

Updated on September 18, 2022

Comments

  • Omar Malas
    Omar Malas over 1 year

    I want to kill all processes with the same name that belong to a user, for example:

    $ps -u user_1
    2345 myapp
    2346 myapp
    2347 myapp
    2348 myapp2
    2349 myapp
    

    I want to kill all "myapp" processes that belong to "user_1", how can I do this?

    • cpast
      cpast over 11 years
      To kill all processes, use killall. I'm not kidding: man killall.
    • dinesh
      dinesh over 11 years
      Here's a link to a discussion on askubuntu that might answer your question.
  • Arpit
    Arpit over 11 years
    and @cpast is right. killall will do the same.
  • rbaleksandar
    rbaleksandar about 6 years
    @Aprit I don'T believe that killall supports wildcards, which forces you to be very precise when passing the name of the process you would like to terminate.