Quickly kill processes containing word

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
1
down vote

favorite












$ ps aux | grep ruby
user 1565 3.7 0.1 4307464 17696 s000 S+ 7:31AM 0:00.61 /Users/user/.rbenv/versions/2.3.1/bin/ruby bin/rails c
user 1579 0.0 0.0 4268020 788 s001 S+ 7:31AM 0:00.00 grep ruby
user 1489 0.0 0.0 0 0 ?? Z 7:29AM 0:00.00 (ruby)


How do I quickly kill all these processes?



What I tried:



kill -9 `ps aux | grep ruby`


My environment:



$ bash --version
GNU bash, version 3.2.57(1)-release (x86_64-apple-darwin18)
Copyright (C) 2007 Free Software Foundation, Inc.
$ uname -a
Darwin MacBook-Pro.local 18.0.0 Darwin Kernel Version 18.0.0: Wed Aug 22 20:13:40 PDT 2018; root:xnu-4903.201.2~1/RELEASE_X86_64 x86_64
$









share|improve this question



















  • 1




    pkill might be the command you're looking for.
    – Haxiel
    Nov 20 at 15:42










  • If any of the answers solved your problem, please accept it by clicking the checkmark next to it. Thank you!
    – Jeff Schaller
    10 hours ago














up vote
1
down vote

favorite












$ ps aux | grep ruby
user 1565 3.7 0.1 4307464 17696 s000 S+ 7:31AM 0:00.61 /Users/user/.rbenv/versions/2.3.1/bin/ruby bin/rails c
user 1579 0.0 0.0 4268020 788 s001 S+ 7:31AM 0:00.00 grep ruby
user 1489 0.0 0.0 0 0 ?? Z 7:29AM 0:00.00 (ruby)


How do I quickly kill all these processes?



What I tried:



kill -9 `ps aux | grep ruby`


My environment:



$ bash --version
GNU bash, version 3.2.57(1)-release (x86_64-apple-darwin18)
Copyright (C) 2007 Free Software Foundation, Inc.
$ uname -a
Darwin MacBook-Pro.local 18.0.0 Darwin Kernel Version 18.0.0: Wed Aug 22 20:13:40 PDT 2018; root:xnu-4903.201.2~1/RELEASE_X86_64 x86_64
$









share|improve this question



















  • 1




    pkill might be the command you're looking for.
    – Haxiel
    Nov 20 at 15:42










  • If any of the answers solved your problem, please accept it by clicking the checkmark next to it. Thank you!
    – Jeff Schaller
    10 hours ago












up vote
1
down vote

favorite









up vote
1
down vote

favorite











$ ps aux | grep ruby
user 1565 3.7 0.1 4307464 17696 s000 S+ 7:31AM 0:00.61 /Users/user/.rbenv/versions/2.3.1/bin/ruby bin/rails c
user 1579 0.0 0.0 4268020 788 s001 S+ 7:31AM 0:00.00 grep ruby
user 1489 0.0 0.0 0 0 ?? Z 7:29AM 0:00.00 (ruby)


How do I quickly kill all these processes?



What I tried:



kill -9 `ps aux | grep ruby`


My environment:



$ bash --version
GNU bash, version 3.2.57(1)-release (x86_64-apple-darwin18)
Copyright (C) 2007 Free Software Foundation, Inc.
$ uname -a
Darwin MacBook-Pro.local 18.0.0 Darwin Kernel Version 18.0.0: Wed Aug 22 20:13:40 PDT 2018; root:xnu-4903.201.2~1/RELEASE_X86_64 x86_64
$









share|improve this question















$ ps aux | grep ruby
user 1565 3.7 0.1 4307464 17696 s000 S+ 7:31AM 0:00.61 /Users/user/.rbenv/versions/2.3.1/bin/ruby bin/rails c
user 1579 0.0 0.0 4268020 788 s001 S+ 7:31AM 0:00.00 grep ruby
user 1489 0.0 0.0 0 0 ?? Z 7:29AM 0:00.00 (ruby)


How do I quickly kill all these processes?



What I tried:



kill -9 `ps aux | grep ruby`


My environment:



$ bash --version
GNU bash, version 3.2.57(1)-release (x86_64-apple-darwin18)
Copyright (C) 2007 Free Software Foundation, Inc.
$ uname -a
Darwin MacBook-Pro.local 18.0.0 Darwin Kernel Version 18.0.0: Wed Aug 22 20:13:40 PDT 2018; root:xnu-4903.201.2~1/RELEASE_X86_64 x86_64
$






process osx kill






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 20 at 18:11









Jeff Schaller

36.4k952120




36.4k952120










asked Nov 20 at 15:34









american-ninja-warrior

1365




1365







  • 1




    pkill might be the command you're looking for.
    – Haxiel
    Nov 20 at 15:42










  • If any of the answers solved your problem, please accept it by clicking the checkmark next to it. Thank you!
    – Jeff Schaller
    10 hours ago












  • 1




    pkill might be the command you're looking for.
    – Haxiel
    Nov 20 at 15:42










  • If any of the answers solved your problem, please accept it by clicking the checkmark next to it. Thank you!
    – Jeff Schaller
    10 hours ago







1




1




pkill might be the command you're looking for.
– Haxiel
Nov 20 at 15:42




pkill might be the command you're looking for.
– Haxiel
Nov 20 at 15:42












If any of the answers solved your problem, please accept it by clicking the checkmark next to it. Thank you!
– Jeff Schaller
10 hours ago




If any of the answers solved your problem, please accept it by clicking the checkmark next to it. Thank you!
– Jeff Schaller
10 hours ago










3 Answers
3






active

oldest

votes

















up vote
2
down vote













As Haxiel commented, my recommendation would be to use pkill:



pkill -9 ruby





share|improve this answer




















  • -9 is it required?
    – GAD3R
    Nov 20 at 18:09






  • 1




    Nope; the OP gave that as the example that they wanted.
    – Jeff Schaller
    Nov 20 at 18:10










  • I'm upvoting your answer. Mine works as well but yours is cleaner and less tedious. I'm aware of the pkill command but I use kill out of habit and didn't want to give misinformation as I didn't have a computer to test at the time.
    – Nasir Riley
    Nov 20 at 19:52










  • I don't have an OSX system at hand, either, but I'm encouraged by the existence of the corresponding man page.
    – Jeff Schaller
    Nov 20 at 19:56

















up vote
1
down vote













kill $(ps aux | grep ruby | grep -v grep | awk 'print $2' | xargs)



for p in $(ps aux | grep ruby | grep -v grep | awk 'print $2'); do kill $p; done



You can substitute kill9 for kill if necessary.






share|improve this answer





























    up vote
    -1
    down vote













    I Tried with below command



    ps -eaf | grep -i ruby| grep -iv 'grep'| awk 'print "kill -9" " " $2'| sh





    share|improve this answer




















    • awk can grep as well as execute system commands, which would remove three of the pipeline commands
      – Jeff Schaller
      Nov 20 at 17:57










    • I Added only awk method
      – Praveen Kumar BS
      Nov 20 at 18:09










    • ps -eaf | grep -i ssh| awk '$(NF-2) !~/grep/print "kill -9" " " $2'| sh
      – Praveen Kumar BS
      Nov 20 at 18:09










    Your Answer








    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "106"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    convertImagesToLinks: false,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    imageUploader:
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    ,
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













     

    draft saved


    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f482996%2fquickly-kill-processes-containing-word%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    3 Answers
    3






    active

    oldest

    votes








    3 Answers
    3






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    2
    down vote













    As Haxiel commented, my recommendation would be to use pkill:



    pkill -9 ruby





    share|improve this answer




















    • -9 is it required?
      – GAD3R
      Nov 20 at 18:09






    • 1




      Nope; the OP gave that as the example that they wanted.
      – Jeff Schaller
      Nov 20 at 18:10










    • I'm upvoting your answer. Mine works as well but yours is cleaner and less tedious. I'm aware of the pkill command but I use kill out of habit and didn't want to give misinformation as I didn't have a computer to test at the time.
      – Nasir Riley
      Nov 20 at 19:52










    • I don't have an OSX system at hand, either, but I'm encouraged by the existence of the corresponding man page.
      – Jeff Schaller
      Nov 20 at 19:56














    up vote
    2
    down vote













    As Haxiel commented, my recommendation would be to use pkill:



    pkill -9 ruby





    share|improve this answer




















    • -9 is it required?
      – GAD3R
      Nov 20 at 18:09






    • 1




      Nope; the OP gave that as the example that they wanted.
      – Jeff Schaller
      Nov 20 at 18:10










    • I'm upvoting your answer. Mine works as well but yours is cleaner and less tedious. I'm aware of the pkill command but I use kill out of habit and didn't want to give misinformation as I didn't have a computer to test at the time.
      – Nasir Riley
      Nov 20 at 19:52










    • I don't have an OSX system at hand, either, but I'm encouraged by the existence of the corresponding man page.
      – Jeff Schaller
      Nov 20 at 19:56












    up vote
    2
    down vote










    up vote
    2
    down vote









    As Haxiel commented, my recommendation would be to use pkill:



    pkill -9 ruby





    share|improve this answer












    As Haxiel commented, my recommendation would be to use pkill:



    pkill -9 ruby






    share|improve this answer












    share|improve this answer



    share|improve this answer










    answered Nov 20 at 17:59









    Jeff Schaller

    36.4k952120




    36.4k952120











    • -9 is it required?
      – GAD3R
      Nov 20 at 18:09






    • 1




      Nope; the OP gave that as the example that they wanted.
      – Jeff Schaller
      Nov 20 at 18:10










    • I'm upvoting your answer. Mine works as well but yours is cleaner and less tedious. I'm aware of the pkill command but I use kill out of habit and didn't want to give misinformation as I didn't have a computer to test at the time.
      – Nasir Riley
      Nov 20 at 19:52










    • I don't have an OSX system at hand, either, but I'm encouraged by the existence of the corresponding man page.
      – Jeff Schaller
      Nov 20 at 19:56
















    • -9 is it required?
      – GAD3R
      Nov 20 at 18:09






    • 1




      Nope; the OP gave that as the example that they wanted.
      – Jeff Schaller
      Nov 20 at 18:10










    • I'm upvoting your answer. Mine works as well but yours is cleaner and less tedious. I'm aware of the pkill command but I use kill out of habit and didn't want to give misinformation as I didn't have a computer to test at the time.
      – Nasir Riley
      Nov 20 at 19:52










    • I don't have an OSX system at hand, either, but I'm encouraged by the existence of the corresponding man page.
      – Jeff Schaller
      Nov 20 at 19:56















    -9 is it required?
    – GAD3R
    Nov 20 at 18:09




    -9 is it required?
    – GAD3R
    Nov 20 at 18:09




    1




    1




    Nope; the OP gave that as the example that they wanted.
    – Jeff Schaller
    Nov 20 at 18:10




    Nope; the OP gave that as the example that they wanted.
    – Jeff Schaller
    Nov 20 at 18:10












    I'm upvoting your answer. Mine works as well but yours is cleaner and less tedious. I'm aware of the pkill command but I use kill out of habit and didn't want to give misinformation as I didn't have a computer to test at the time.
    – Nasir Riley
    Nov 20 at 19:52




    I'm upvoting your answer. Mine works as well but yours is cleaner and less tedious. I'm aware of the pkill command but I use kill out of habit and didn't want to give misinformation as I didn't have a computer to test at the time.
    – Nasir Riley
    Nov 20 at 19:52












    I don't have an OSX system at hand, either, but I'm encouraged by the existence of the corresponding man page.
    – Jeff Schaller
    Nov 20 at 19:56




    I don't have an OSX system at hand, either, but I'm encouraged by the existence of the corresponding man page.
    – Jeff Schaller
    Nov 20 at 19:56












    up vote
    1
    down vote













    kill $(ps aux | grep ruby | grep -v grep | awk 'print $2' | xargs)



    for p in $(ps aux | grep ruby | grep -v grep | awk 'print $2'); do kill $p; done



    You can substitute kill9 for kill if necessary.






    share|improve this answer


























      up vote
      1
      down vote













      kill $(ps aux | grep ruby | grep -v grep | awk 'print $2' | xargs)



      for p in $(ps aux | grep ruby | grep -v grep | awk 'print $2'); do kill $p; done



      You can substitute kill9 for kill if necessary.






      share|improve this answer
























        up vote
        1
        down vote










        up vote
        1
        down vote









        kill $(ps aux | grep ruby | grep -v grep | awk 'print $2' | xargs)



        for p in $(ps aux | grep ruby | grep -v grep | awk 'print $2'); do kill $p; done



        You can substitute kill9 for kill if necessary.






        share|improve this answer














        kill $(ps aux | grep ruby | grep -v grep | awk 'print $2' | xargs)



        for p in $(ps aux | grep ruby | grep -v grep | awk 'print $2'); do kill $p; done



        You can substitute kill9 for kill if necessary.







        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Nov 20 at 16:13

























        answered Nov 20 at 15:48









        Nasir Riley

        2,176239




        2,176239




















            up vote
            -1
            down vote













            I Tried with below command



            ps -eaf | grep -i ruby| grep -iv 'grep'| awk 'print "kill -9" " " $2'| sh





            share|improve this answer




















            • awk can grep as well as execute system commands, which would remove three of the pipeline commands
              – Jeff Schaller
              Nov 20 at 17:57










            • I Added only awk method
              – Praveen Kumar BS
              Nov 20 at 18:09










            • ps -eaf | grep -i ssh| awk '$(NF-2) !~/grep/print "kill -9" " " $2'| sh
              – Praveen Kumar BS
              Nov 20 at 18:09














            up vote
            -1
            down vote













            I Tried with below command



            ps -eaf | grep -i ruby| grep -iv 'grep'| awk 'print "kill -9" " " $2'| sh





            share|improve this answer




















            • awk can grep as well as execute system commands, which would remove three of the pipeline commands
              – Jeff Schaller
              Nov 20 at 17:57










            • I Added only awk method
              – Praveen Kumar BS
              Nov 20 at 18:09










            • ps -eaf | grep -i ssh| awk '$(NF-2) !~/grep/print "kill -9" " " $2'| sh
              – Praveen Kumar BS
              Nov 20 at 18:09












            up vote
            -1
            down vote










            up vote
            -1
            down vote









            I Tried with below command



            ps -eaf | grep -i ruby| grep -iv 'grep'| awk 'print "kill -9" " " $2'| sh





            share|improve this answer












            I Tried with below command



            ps -eaf | grep -i ruby| grep -iv 'grep'| awk 'print "kill -9" " " $2'| sh






            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Nov 20 at 16:28









            Praveen Kumar BS

            1,094138




            1,094138











            • awk can grep as well as execute system commands, which would remove three of the pipeline commands
              – Jeff Schaller
              Nov 20 at 17:57










            • I Added only awk method
              – Praveen Kumar BS
              Nov 20 at 18:09










            • ps -eaf | grep -i ssh| awk '$(NF-2) !~/grep/print "kill -9" " " $2'| sh
              – Praveen Kumar BS
              Nov 20 at 18:09
















            • awk can grep as well as execute system commands, which would remove three of the pipeline commands
              – Jeff Schaller
              Nov 20 at 17:57










            • I Added only awk method
              – Praveen Kumar BS
              Nov 20 at 18:09










            • ps -eaf | grep -i ssh| awk '$(NF-2) !~/grep/print "kill -9" " " $2'| sh
              – Praveen Kumar BS
              Nov 20 at 18:09















            awk can grep as well as execute system commands, which would remove three of the pipeline commands
            – Jeff Schaller
            Nov 20 at 17:57




            awk can grep as well as execute system commands, which would remove three of the pipeline commands
            – Jeff Schaller
            Nov 20 at 17:57












            I Added only awk method
            – Praveen Kumar BS
            Nov 20 at 18:09




            I Added only awk method
            – Praveen Kumar BS
            Nov 20 at 18:09












            ps -eaf | grep -i ssh| awk '$(NF-2) !~/grep/print "kill -9" " " $2'| sh
            – Praveen Kumar BS
            Nov 20 at 18:09




            ps -eaf | grep -i ssh| awk '$(NF-2) !~/grep/print "kill -9" " " $2'| sh
            – Praveen Kumar BS
            Nov 20 at 18:09

















             

            draft saved


            draft discarded















































             


            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f482996%2fquickly-kill-processes-containing-word%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown






            Popular posts from this blog

            How to check contact read email or not when send email to Individual?

            Displaying single band from multi-band raster using QGIS

            How many registers does an x86_64 CPU actually have?