kill process that run more then 1 day | Unix Linux Forums | AIX

  Go Back    


AIX AIX is IBM's industry-leading UNIX operating system that meets the demands of applications that businesses rely upon in today's marketplace.

kill process that run more then 1 day

AIX


Tags
aix, unix

Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 04-11-2010
Elii Elii is offline
Registered User
 
Join Date: Jul 2009
Last Activity: 2 June 2010, 8:09 AM EDT
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
kill process that run more then 1 day

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
Sponsored Links
    #2  
Old 04-12-2010
amitranjansahu's Avatar
amitranjansahu amitranjansahu is offline
Registered User
 
Join Date: Jan 2009
Last Activity: 6 February 2014, 9:06 AM EST
Location: Bangalore,INDIA
Posts: 507
Thanks: 4
Thanked 27 Times in 27 Posts
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.


Code:
YEST=`TZ="GMT+24" date | awk ' { print $2 , $3 } '`


ps -aef | grep "xxx" | grep "$YEST" | grep -v grep | awk ' { print $2 } '

Sponsored Links
    #3  
Old 04-12-2010
Elii Elii is offline
Registered User
 
Join Date: Jul 2009
Last Activity: 2 June 2010, 8:09 AM EDT
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Hi

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
    #4  
Old 04-12-2010
amitranjansahu's Avatar
amitranjansahu amitranjansahu is offline
Registered User
 
Join Date: Jan 2009
Last Activity: 6 February 2014, 9:06 AM EST
Location: Bangalore,INDIA
Posts: 507
Thanks: 4
Thanked 27 Times in 27 Posts
Ohh I got it wrong

Any way you can use etime to get the process run for more than 1 day


Code:
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.
Sponsored Links
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Shell Script to Kill Process(number of process) Unix/Solaris jonnyvic Shell Programming and Scripting 2 12-03-2009 01:44 PM
Kill a process without using kill command sudhamacs Linux 6 10-27-2008 12:36 PM
Kill a process without using kill command sudhamacs Shell Programming and Scripting 0 10-01-2008 05:19 PM
how to start a process and make it sleep for 5 mins and then kill that process shrao Shell Programming and Scripting 6 03-27-2007 12:54 PM
When kill doesnt work, how to kill a process ? VijayHegde UNIX for Advanced & Expert Users 3 05-12-2006 04:24 PM



All times are GMT -4. The time now is 03:29 AM.