[REQ] Automatic script kill process

HI,
I'm using CentOS 5.1 x86_64, CPanel ..
a lot of my users used too much resource, i want to write a script to kill all of them.
Eg: LFD always notify me:

Time: Sun Apr 27 07:40:08 2008
Account: xxxx (my user)
Resource: Virtual Memory Size
Exceeded: 110 > 100 (MB)
Executable: /usr/bin/php
Command Line: php /home/xxxx/public_html/import.php
PID: 20897
Killed: No

or .

Time: Sat Apr 26 18:40:50 2008
Account: xxxx (my user)
Resource: Process Time
Exceeded: 7305 > 1800 (seconds)
Executable: /usr/bin/php
Command Line: /usr/bin/php /home/xxxx/public_html/index.php
PID: 27308
Killed: No

Now, can you help me ??

what is that you are trying to achieve ?

what is the difficulty in the approach or answer you had tried ?

Could you please post what you had tried first ? :slight_smile:

Sorry, i'm not good at English.
I found out the option of csf (ConfigServer Security & Firewall) to kill all process over 180 seconds and over 100Mb RAM resource.
And now, i want you help me write a script kill all mySQL process over 15 seconds :slight_smile: anyone can help me ?
I'm using CentOS 5.1 and Cpanel

Well, if you want to kill everything from a specific daemon then i guess you could use this

PID=`ps -ef |grep mysql |grep -v grep | awk '{print $2}'`
for i in $PID; do echo "killing MySQL process with PID = $i"; kill -9 $i; done

bare in mind that this will also kill the MySQL daemon...Therefore better used as a stop script.