Kill all processes that are running for more than 5 minutes by a given user in linux bash script

I need the command to kill processes that have been running since at least 5 minutes for a given process.

I will have to run that command every five minutes or so.

Thanks a million !

(system is Centos5)


kill -9 $(ps -eo comm,pid,etimes | awk '/^procname/ {if ($3 > 300) { print $2}}')

where "procname" is a process name and 300 is running time threshold


Maybe run the long running command like this in a crontab?

timeout -k 300 command