terminate the process

In my system , there are a system user "cronusr" , it is mainly to run the crontab job in the database .Sometimes the cronjob process will be failure ( due to some reason ) so that many cronusr process are in the system , it affect other process in the system ,

I want to have a script that can kill the process - the process owner is cronusr and it is idle for one hour ( I think it can check by ps -aux |grep pid , if the status is R , then it is running , if it is S , then it is sleep and the process can be termiated ) , could suggest the script for the case ? thx in advance.

How about this ?

#! /bin/sh

if [ "ps -aux | grep pid | grep cronusr | awk '{ print $8 }'" == S ] ; then
kill -9 pid
fi

Not tested.

Post the results.

Vino

This should be better off.

#! /bin/sh

[ `ps -aux | grep mutt | grep username | awk '{ print $8 }'` == S ] && kill -9 pid                    

Vino