The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
Google UNIX.COM


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 !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
is there a way to find out the tty from which the process is launched sleepy_11 UNIX for Advanced & Expert Users 1 04-07-2008 02:08 AM
Find CPU per process in AIX yamsin789 Shell Programming and Scripting 0 10-31-2007 12:23 AM
How to find which process is using up too much CPU 0ktalmagik SUN Solaris 1 06-03-2006 12:48 AM
how to find the chid process id from given parent process id guhas Shell Programming and Scripting 3 10-13-2005 05:13 AM
find eof, then process mfilby Shell Programming and Scripting 12 12-22-2003 03:29 PM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 02-02-2006
MizzGail's Avatar
Registered User
 

Join Date: Sep 2001
Location: Syracuse, NY
Posts: 158
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!
Reply With Quote
Forum Sponsor
  #2  
Old 02-02-2006
vino's Avatar
Supporter (in vino veritas)
 

Join Date: Feb 2005
Location: Bangalore, India
Posts: 2,699
See if this appraoch helps - check the process
Reply With Quote
  #3  
Old 02-03-2006
MizzGail's Avatar
Registered User
 

Join Date: Sep 2001
Location: Syracuse, NY
Posts: 158
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!
Reply With Quote
  #4  
Old 02-03-2006
Perderabo's Avatar
Unix Daemon
 

Join Date: Aug 2001
Location: Washington DC Area
Posts: 8,667
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}')
Reply With Quote
  #5  
Old 02-03-2006
MizzGail's Avatar
Registered User
 

Join Date: Sep 2001
Location: Syracuse, NY
Posts: 158
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!
Reply With Quote
  #6  
Old 02-03-2006
Perderabo's Avatar
Unix Daemon
 

Join Date: Aug 2001
Location: Washington DC Area
Posts: 8,667
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.
Reply With Quote
  #7  
Old 03-08-2006
MizzGail's Avatar
Registered User
 

Join Date: Sep 2001
Location: Syracuse, NY
Posts: 158
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.
Reply With Quote
Google The UNIX and Linux Forums
Reply

Tags
mtime

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 08:55 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0