![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| 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 !! |
|
|
||||
| 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 |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
||||
|
||||
|
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! |
| Forum Sponsor | ||
|
|
|
#2
|
||||
|
||||
|
See if this appraoch helps - check the process
|
|
#3
|
||||
|
||||
|
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
|
||||
|
||||
|
Quote:
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}') |
|
#5
|
||||
|
||||
|
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! |
|
#6
|
||||
|
||||
|
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. |
|
#7
|
||||
|
||||
|
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. |
||||
| Google The UNIX and Linux Forums |