hi all
i need a script which will find all the processes witht the name of xxx and kill all those processes that runs for more than 1 day.
Regards
hi all
i need a script which will find all the processes witht the name of xxx and kill all those processes that runs for more than 1 day.
Regards
Here is the idea to kill last days process.
Get the last day . Then grep the process xxx and last day . You will get the PID's . Then in a for loop kill all the PID's. I have posted the code to get the last day and get the pid's.
YEST=`TZ="GMT+24" date | awk ' { print $2 , $3 } '`
ps -aef | grep "xxx" | grep "$YEST" | grep -v grep | awk ' { print $2 } '
that is greate but it returns the process that run for over exactly one day.
if i want to get the processes that run >=1 day (one day and above)
thanks
Ohh I got it wrong
Any way you can use etime to get the process run for more than 1 day
amit@alu /export/home/amit $ ps -aef -o user,pid,etime,args | grep oracle
oracle 637 64-01:26:08 /oracle/product/102/db/bin/tnslsnr LISTENER -inherit
Here the etime gives you the days-hh:min:sec the procees is running.
So validating this value you can kill the process in a loop .
The process started within 24 hours will have only hh:mm:ss in etime where as for procs running more than 24 hr dd-hh:mm:ss will be there.