Please whitelist cPanel in your adblocker so that you’re able to see our version release promotions, thanks!

The Community Forums

Interact with an entire community of cPanel & WHM users!

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:
    56
    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:
    8
    Trophy Points:
    68
    Location:
    Athens Greece
    whm-Process Manager- you can trace or kill a process
    or by the kill command
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  3. ModServ

    ModServ Well-Known Member

    Joined:
    Oct 17, 2006
    Messages:
    332
    Likes Received:
    5
    Trophy Points:
    168
    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!
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
    #3 ModServ, Sep 6, 2011
    Last edited: Sep 6, 2011
Loading...

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice