The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Kill a process based on command?

Discussion in 'Security' started by nobodyk, Sep 5, 2011.

  1. nobodyk

    nobodyk Well-Known Member

    Joined:
    Aug 1, 2010
    Messages:
    90
    Likes Received:
    0
    Trophy Points:
    6
    Does anyone know how to kill a process base on a command?

    Example:

    The owner is "user" and the command is "/usr/bin/php /home/user/public_html/file.php"

    How do I kill all process that run the command "/usr/bin/php /home/user/public_html/file.php" under the owner "user"?

    Is this possible with cpanel or would a basic sh script work in this case? I don't mind a script looping every 10 seconds or so.
     
  2. k-planethost

    k-planethost Well-Known Member

    Joined:
    Sep 22, 2009
    Messages:
    199
    Likes Received:
    4
    Trophy Points:
    18
    Location:
    Athens Greece
    whm-Process Manager- you can trace or kill a process
    or by the kill command
     
  3. ModServ

    ModServ Well-Known Member

    Joined:
    Oct 17, 2006
    Messages:
    332
    Likes Received:
    5
    Trophy Points:
    18
    Location:
    Egypt
    cPanel Access Level:
    Root Administrator
    You can do this:

    Code:
    for i in `ps aux | grep "PROCESSNAME" | awk '{ print $2 }'`; do kill -9 $i ; done
    change PROCESSNAME to what process you want to bulk kill.

    And you can make it as a loop if you want, something like that

    Code:
    while [ DATA ]
    do
    for i in `ps aux | grep "PROCESSNAME" | awk '{ print $2 }'`; do kill -9 $i ; sleep 10; done
    Greetz!
     
    #3 ModServ, Sep 6, 2011
    Last edited: Sep 6, 2011
Loading...

Share This Page