find a process age | Unix Linux Forums | UNIX for Dummies Questions & Answers

  Go Back    


UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

find a process age

UNIX for Dummies Questions & Answers


Tags
mtime

Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 02-02-2006
MizzGail's Avatar
MizzGail MizzGail is offline
Registered User
 
Join Date: Sep 2001
Last Activity: 20 August 2014, 9:58 AM EDT
Location: Syracuse, NY
Posts: 164
Thanks: 0
Thanked 0 Times in 0 Posts
find a process age

I can write a script to use ps and interigate the output, but is there a command that works similar to the find command for files where I can request a list of all the running processes over 1 day old ?

thanks!
Sponsored Links
    #2  
Old 02-02-2006
vino's Avatar
vino vino is offline Forum Advisor  
Supporter (in vino veritas)
 
Join Date: Feb 2005
Last Activity: 9 April 2013, 8:19 AM EDT
Location: Sydney, Down Under
Posts: 2,847
Thanks: 0
Thanked 12 Times in 12 Posts
See if this appraoch helps - check the process
Sponsored Links
    #3  
Old 02-03-2006
MizzGail's Avatar
MizzGail MizzGail is offline
Registered User
 
Join Date: Sep 2001
Last Activity: 20 August 2014, 9:58 AM EDT
Location: Syracuse, NY
Posts: 164
Thanks: 0
Thanked 0 Times in 0 Posts
The situation is I have some processes that revert to uid 1 when they disconnect from the application. I can write a script that will awk out the uid, pid and time and kill anything that has reverted to uid 1. These hung processes also retain an application license until they die.

I know with the find command I can request a list of files over -mtime +n

I was just wondering if there was anyting that simple to tell me what process there are that are over "n" number of days old..

thanks!
    #4  
Old 02-03-2006
Perderabo's Avatar
Perderabo Perderabo is offline Forum Staff  
Unix Daemon (Administrator Emeritus)
 
Join Date: Aug 2001
Last Activity: 18 September 2014, 2:40 PM EDT
Location: Ashburn, Virginia
Posts: 9,925
Thanks: 60
Thanked 435 Times in 260 Posts
Quote:
Originally Posted by MizzGail
some processes that revert to uid 1 when they disconnect from the application.
Hmmm...that does not compute. You must mean that their parent dies and they become adopted by init. These processes have a ppid of 1. Easy to find those:

ps -ef | awk '$3 == 1'

As always use nawk instead of awk on Suns. The above code gives everything with a ppid of 1. You want only some of those. Maybe you can match something in the command line. Let's say all of the processes you want have abcxyz in the command line:

ps -ef | awk '$3 == 1 && $8 ~ "abcxyz"'

Now you should have a list of just the processes you want. Want just the pid's?

ps -ef | awk '$3 == 1 && $8 ~ "abcxyz" {print $2}'

Wanna kill 'em?

kill $(ps -ef | awk '$3 == 1 && $8 ~ "abcxyz" {print $2}')
Sponsored Links
    #5  
Old 02-03-2006
MizzGail's Avatar
MizzGail MizzGail is offline
Registered User
 
Join Date: Sep 2001
Last Activity: 20 August 2014, 9:58 AM EDT
Location: Syracuse, NY
Posts: 164
Thanks: 0
Thanked 0 Times in 0 Posts
Yes. sorry... ppid = 1.

The script will work, I was just wondering if there was a command that I didn't know about to get the age of a process....
thanks!
Sponsored Links
    #6  
Old 02-03-2006
Perderabo's Avatar
Perderabo Perderabo is offline Forum Staff  
Unix Daemon (Administrator Emeritus)
 
Join Date: Aug 2001
Last Activity: 18 September 2014, 2:40 PM EDT
Location: Ashburn, Virginia
Posts: 9,925
Thanks: 60
Thanked 435 Times in 260 Posts
I don't understand how the process age fits into this problem. In general, no, it is hard to get the age of a process. The tools mostly display start time. So you need to do calculations. I believe that you use SunOS, though. Bear in mind that on a Sun, you can using the find command on processes by using /proc. Each process gets a subdirectory. So as root you can do:
cd /proc
find . ! -name . -prune -mtime +3 -print | xargs ls -ld
or something like that.
Sponsored Links
    #7  
Old 03-08-2006
MizzGail's Avatar
MizzGail MizzGail is offline
Registered User
 
Join Date: Sep 2001
Last Activity: 20 August 2014, 9:58 AM EDT
Location: Syracuse, NY
Posts: 164
Thanks: 0
Thanked 0 Times in 0 Posts
I forgot about the /proc directory. I can incorporate that into my logic. thanks!

Why I want to know the age is that I try to give these processes time to clean themselves up just incase they are still processing something even though they are no longer connected to the application.
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
Find CPU per process in AIX yamsin789 AIX 1 04-01-2009 07:13 AM
How to find out how much RAM that process is using redlotus72 UNIX for Dummies Questions & Answers 3 08-08-2008 10:22 AM
How to find which process is using up too much CPU 0ktalmagik Solaris 1 06-03-2006 03:48 AM
how to find the chid process id from given parent process id guhas Shell Programming and Scripting 3 10-13-2005 08:13 AM
find eof, then process mfilby Shell Programming and Scripting 12 12-22-2003 05:29 PM



All times are GMT -4. The time now is 03:43 PM.