How to kill all process with given name?

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











up vote
9
down vote

favorite
2












I run command ps -A | grep <application_name> and getting list of process like this:



19440 ? 00:00:11 <application_name>
21630 ? 00:00:00 <application_name>
22694 ? 00:00:00 <application_name>


I want to kill all process from the list: 19440, 21630, 22694.



I have tried ps -A | grep <application_name> | xargs kill -9 $1 but it works with errors.



kill: illegal pid ?
kill: illegal pid 00:00:00
kill: illegal pid <application_name>


How can I do this gracefully?










share|improve this question



















  • 2




    Look into pkill...
    – Jeff Schaller
    Oct 13 '16 at 0:29














up vote
9
down vote

favorite
2












I run command ps -A | grep <application_name> and getting list of process like this:



19440 ? 00:00:11 <application_name>
21630 ? 00:00:00 <application_name>
22694 ? 00:00:00 <application_name>


I want to kill all process from the list: 19440, 21630, 22694.



I have tried ps -A | grep <application_name> | xargs kill -9 $1 but it works with errors.



kill: illegal pid ?
kill: illegal pid 00:00:00
kill: illegal pid <application_name>


How can I do this gracefully?










share|improve this question



















  • 2




    Look into pkill...
    – Jeff Schaller
    Oct 13 '16 at 0:29












up vote
9
down vote

favorite
2









up vote
9
down vote

favorite
2






2





I run command ps -A | grep <application_name> and getting list of process like this:



19440 ? 00:00:11 <application_name>
21630 ? 00:00:00 <application_name>
22694 ? 00:00:00 <application_name>


I want to kill all process from the list: 19440, 21630, 22694.



I have tried ps -A | grep <application_name> | xargs kill -9 $1 but it works with errors.



kill: illegal pid ?
kill: illegal pid 00:00:00
kill: illegal pid <application_name>


How can I do this gracefully?










share|improve this question















I run command ps -A | grep <application_name> and getting list of process like this:



19440 ? 00:00:11 <application_name>
21630 ? 00:00:00 <application_name>
22694 ? 00:00:00 <application_name>


I want to kill all process from the list: 19440, 21630, 22694.



I have tried ps -A | grep <application_name> | xargs kill -9 $1 but it works with errors.



kill: illegal pid ?
kill: illegal pid 00:00:00
kill: illegal pid <application_name>


How can I do this gracefully?







grep process kill ps






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Oct 13 '16 at 9:09









Jeff Schaller

32.6k849110




32.6k849110










asked Oct 13 '16 at 0:29









Łukasz D. Tulikowski

288128




288128







  • 2




    Look into pkill...
    – Jeff Schaller
    Oct 13 '16 at 0:29












  • 2




    Look into pkill...
    – Jeff Schaller
    Oct 13 '16 at 0:29







2




2




Look into pkill...
– Jeff Schaller
Oct 13 '16 at 0:29




Look into pkill...
– Jeff Schaller
Oct 13 '16 at 0:29










3 Answers
3






active

oldest

votes

















up vote
14
down vote



accepted










pkill -f <application_na>


Will kill all the processes that contain the pattern <application_na> in their names.



man pkill






share|improve this answer





























    up vote
    8
    down vote













    The problem is that ps -A | grep <application_name> | xargs -n1 returns output like this



    19440
    ?
    00:00:11
    <application_name>
    21630
    ?
    00:00:00
    <application_name>
    22694
    ?
    00:00:00
    <application_name>


    You can use awk to a get first a column of ps output.



    ps -A | grep <application_name> | awk 'print $1' | xargs -n1


    Will return list of PIDs



    19440
    21630
    22694


    And adding kill -9 $1 you have a command which kills all PIDs



    ps -A | grep <application_name> | awk 'print $1' | xargs --no-run-if-empty kill -9 $1





    share|improve this answer






















    • this is perfect I test it on bash script it's kills the processer immediatly with no errors + even if the process is'nt started it shows no errors which is what I want , here example of ffmpeg processer killer , nano /usr/bin/ffmpegk . . . . ps -A | grep ffmpeg | awk 'print $1' | xargs kill -9 $1 . . . . chmod a+rx /usr/bin/ffmpegk
      – Salem F
      May 21 at 12:26











    • I have a problem with this where I get the output of kill -9 if no process matches
      – Daniel F
      Aug 19 at 12:46

















    up vote
    0
    down vote













    killall can do that.



    $ killall application_name





    share|improve this answer




















    • Is kill all allowing regular expression in an application name?
      – Åukasz D. Tulikowski
      Oct 13 '16 at 0:59










    • killall --regexp "appl.*me" Though there might be different killall implementations. See man killall.
      – rudimeier
      Oct 13 '16 at 1:02











    • killall not enough sometimes I need to send it three time to kill the process , and even fail to kill it , the only fast working solution fo me is kill -9 pid I think @ŁukaszD.Tulikowski is the best working solution specially for bash scripts .
      – Salem F
      May 21 at 12:16











    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: false,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    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%2f316065%2fhow-to-kill-all-process-with-given-name%23new-answer', 'question_page');

    );

    Post as a guest






























    3 Answers
    3






    active

    oldest

    votes








    3 Answers
    3






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    14
    down vote



    accepted










    pkill -f <application_na>


    Will kill all the processes that contain the pattern <application_na> in their names.



    man pkill






    share|improve this answer


























      up vote
      14
      down vote



      accepted










      pkill -f <application_na>


      Will kill all the processes that contain the pattern <application_na> in their names.



      man pkill






      share|improve this answer
























        up vote
        14
        down vote



        accepted







        up vote
        14
        down vote



        accepted






        pkill -f <application_na>


        Will kill all the processes that contain the pattern <application_na> in their names.



        man pkill






        share|improve this answer














        pkill -f <application_na>


        Will kill all the processes that contain the pattern <application_na> in their names.



        man pkill







        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Oct 13 '16 at 21:16









        Gilles

        510k12010081537




        510k12010081537










        answered Oct 13 '16 at 7:17









        Katu

        52828




        52828






















            up vote
            8
            down vote













            The problem is that ps -A | grep <application_name> | xargs -n1 returns output like this



            19440
            ?
            00:00:11
            <application_name>
            21630
            ?
            00:00:00
            <application_name>
            22694
            ?
            00:00:00
            <application_name>


            You can use awk to a get first a column of ps output.



            ps -A | grep <application_name> | awk 'print $1' | xargs -n1


            Will return list of PIDs



            19440
            21630
            22694


            And adding kill -9 $1 you have a command which kills all PIDs



            ps -A | grep <application_name> | awk 'print $1' | xargs --no-run-if-empty kill -9 $1





            share|improve this answer






















            • this is perfect I test it on bash script it's kills the processer immediatly with no errors + even if the process is'nt started it shows no errors which is what I want , here example of ffmpeg processer killer , nano /usr/bin/ffmpegk . . . . ps -A | grep ffmpeg | awk 'print $1' | xargs kill -9 $1 . . . . chmod a+rx /usr/bin/ffmpegk
              – Salem F
              May 21 at 12:26











            • I have a problem with this where I get the output of kill -9 if no process matches
              – Daniel F
              Aug 19 at 12:46














            up vote
            8
            down vote













            The problem is that ps -A | grep <application_name> | xargs -n1 returns output like this



            19440
            ?
            00:00:11
            <application_name>
            21630
            ?
            00:00:00
            <application_name>
            22694
            ?
            00:00:00
            <application_name>


            You can use awk to a get first a column of ps output.



            ps -A | grep <application_name> | awk 'print $1' | xargs -n1


            Will return list of PIDs



            19440
            21630
            22694


            And adding kill -9 $1 you have a command which kills all PIDs



            ps -A | grep <application_name> | awk 'print $1' | xargs --no-run-if-empty kill -9 $1





            share|improve this answer






















            • this is perfect I test it on bash script it's kills the processer immediatly with no errors + even if the process is'nt started it shows no errors which is what I want , here example of ffmpeg processer killer , nano /usr/bin/ffmpegk . . . . ps -A | grep ffmpeg | awk 'print $1' | xargs kill -9 $1 . . . . chmod a+rx /usr/bin/ffmpegk
              – Salem F
              May 21 at 12:26











            • I have a problem with this where I get the output of kill -9 if no process matches
              – Daniel F
              Aug 19 at 12:46












            up vote
            8
            down vote










            up vote
            8
            down vote









            The problem is that ps -A | grep <application_name> | xargs -n1 returns output like this



            19440
            ?
            00:00:11
            <application_name>
            21630
            ?
            00:00:00
            <application_name>
            22694
            ?
            00:00:00
            <application_name>


            You can use awk to a get first a column of ps output.



            ps -A | grep <application_name> | awk 'print $1' | xargs -n1


            Will return list of PIDs



            19440
            21630
            22694


            And adding kill -9 $1 you have a command which kills all PIDs



            ps -A | grep <application_name> | awk 'print $1' | xargs --no-run-if-empty kill -9 $1





            share|improve this answer














            The problem is that ps -A | grep <application_name> | xargs -n1 returns output like this



            19440
            ?
            00:00:11
            <application_name>
            21630
            ?
            00:00:00
            <application_name>
            22694
            ?
            00:00:00
            <application_name>


            You can use awk to a get first a column of ps output.



            ps -A | grep <application_name> | awk 'print $1' | xargs -n1


            Will return list of PIDs



            19440
            21630
            22694


            And adding kill -9 $1 you have a command which kills all PIDs



            ps -A | grep <application_name> | awk 'print $1' | xargs --no-run-if-empty kill -9 $1






            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited Aug 19 at 19:49









            Daniel F

            17812




            17812










            answered Oct 13 '16 at 0:57









            Łukasz D. Tulikowski

            288128




            288128











            • this is perfect I test it on bash script it's kills the processer immediatly with no errors + even if the process is'nt started it shows no errors which is what I want , here example of ffmpeg processer killer , nano /usr/bin/ffmpegk . . . . ps -A | grep ffmpeg | awk 'print $1' | xargs kill -9 $1 . . . . chmod a+rx /usr/bin/ffmpegk
              – Salem F
              May 21 at 12:26











            • I have a problem with this where I get the output of kill -9 if no process matches
              – Daniel F
              Aug 19 at 12:46
















            • this is perfect I test it on bash script it's kills the processer immediatly with no errors + even if the process is'nt started it shows no errors which is what I want , here example of ffmpeg processer killer , nano /usr/bin/ffmpegk . . . . ps -A | grep ffmpeg | awk 'print $1' | xargs kill -9 $1 . . . . chmod a+rx /usr/bin/ffmpegk
              – Salem F
              May 21 at 12:26











            • I have a problem with this where I get the output of kill -9 if no process matches
              – Daniel F
              Aug 19 at 12:46















            this is perfect I test it on bash script it's kills the processer immediatly with no errors + even if the process is'nt started it shows no errors which is what I want , here example of ffmpeg processer killer , nano /usr/bin/ffmpegk . . . . ps -A | grep ffmpeg | awk 'print $1' | xargs kill -9 $1 . . . . chmod a+rx /usr/bin/ffmpegk
            – Salem F
            May 21 at 12:26





            this is perfect I test it on bash script it's kills the processer immediatly with no errors + even if the process is'nt started it shows no errors which is what I want , here example of ffmpeg processer killer , nano /usr/bin/ffmpegk . . . . ps -A | grep ffmpeg | awk 'print $1' | xargs kill -9 $1 . . . . chmod a+rx /usr/bin/ffmpegk
            – Salem F
            May 21 at 12:26













            I have a problem with this where I get the output of kill -9 if no process matches
            – Daniel F
            Aug 19 at 12:46




            I have a problem with this where I get the output of kill -9 if no process matches
            – Daniel F
            Aug 19 at 12:46










            up vote
            0
            down vote













            killall can do that.



            $ killall application_name





            share|improve this answer




















            • Is kill all allowing regular expression in an application name?
              – Åukasz D. Tulikowski
              Oct 13 '16 at 0:59










            • killall --regexp "appl.*me" Though there might be different killall implementations. See man killall.
              – rudimeier
              Oct 13 '16 at 1:02











            • killall not enough sometimes I need to send it three time to kill the process , and even fail to kill it , the only fast working solution fo me is kill -9 pid I think @ŁukaszD.Tulikowski is the best working solution specially for bash scripts .
              – Salem F
              May 21 at 12:16















            up vote
            0
            down vote













            killall can do that.



            $ killall application_name





            share|improve this answer




















            • Is kill all allowing regular expression in an application name?
              – Åukasz D. Tulikowski
              Oct 13 '16 at 0:59










            • killall --regexp "appl.*me" Though there might be different killall implementations. See man killall.
              – rudimeier
              Oct 13 '16 at 1:02











            • killall not enough sometimes I need to send it three time to kill the process , and even fail to kill it , the only fast working solution fo me is kill -9 pid I think @ŁukaszD.Tulikowski is the best working solution specially for bash scripts .
              – Salem F
              May 21 at 12:16













            up vote
            0
            down vote










            up vote
            0
            down vote









            killall can do that.



            $ killall application_name





            share|improve this answer












            killall can do that.



            $ killall application_name






            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Oct 13 '16 at 0:53









            rudimeier

            5,2321532




            5,2321532











            • Is kill all allowing regular expression in an application name?
              – Åukasz D. Tulikowski
              Oct 13 '16 at 0:59










            • killall --regexp "appl.*me" Though there might be different killall implementations. See man killall.
              – rudimeier
              Oct 13 '16 at 1:02











            • killall not enough sometimes I need to send it three time to kill the process , and even fail to kill it , the only fast working solution fo me is kill -9 pid I think @ŁukaszD.Tulikowski is the best working solution specially for bash scripts .
              – Salem F
              May 21 at 12:16

















            • Is kill all allowing regular expression in an application name?
              – Åukasz D. Tulikowski
              Oct 13 '16 at 0:59










            • killall --regexp "appl.*me" Though there might be different killall implementations. See man killall.
              – rudimeier
              Oct 13 '16 at 1:02











            • killall not enough sometimes I need to send it three time to kill the process , and even fail to kill it , the only fast working solution fo me is kill -9 pid I think @ŁukaszD.Tulikowski is the best working solution specially for bash scripts .
              – Salem F
              May 21 at 12:16
















            Is kill all allowing regular expression in an application name?
            – Åukasz D. Tulikowski
            Oct 13 '16 at 0:59




            Is kill all allowing regular expression in an application name?
            – Åukasz D. Tulikowski
            Oct 13 '16 at 0:59












            killall --regexp "appl.*me" Though there might be different killall implementations. See man killall.
            – rudimeier
            Oct 13 '16 at 1:02





            killall --regexp "appl.*me" Though there might be different killall implementations. See man killall.
            – rudimeier
            Oct 13 '16 at 1:02













            killall not enough sometimes I need to send it three time to kill the process , and even fail to kill it , the only fast working solution fo me is kill -9 pid I think @ŁukaszD.Tulikowski is the best working solution specially for bash scripts .
            – Salem F
            May 21 at 12:16





            killall not enough sometimes I need to send it three time to kill the process , and even fail to kill it , the only fast working solution fo me is kill -9 pid I think @ŁukaszD.Tulikowski is the best working solution specially for bash scripts .
            – Salem F
            May 21 at 12:16


















             

            draft saved


            draft discarded















































             


            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f316065%2fhow-to-kill-all-process-with-given-name%23new-answer', 'question_page');

            );

            Post as a guest













































































            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?