tags:

views:

52

answers:

1

You can get underground processes by

ps ux

I am searching a way to find processes to which I have not touched for 30 minutes.

How can you find processes unused for an half hour?

+4  A: 

Define "untouched" and "unused". You can find out lots of things using the f parameter on ps(1) in BSD-like systems, the -o on Solaris and Sys/V-like systems.

Update

Responding to the comment:

Well, you can do it. Consider, for example, something that does a periodic ps, and stores the CPU time used along with time. (Actually, you could do this better with a C program calling the appropriate system calls, but that's really an implementation detail.) Store sample time and PID, and watch for the PID's CPU time not having changed over the appropriate interval. This could even be implemented with an awk or perl program like

while true; do
  ps _flags_
  sleep 30
done | awk -f myprog | tail -f

so that every time awk gets a ps output, it mangles it, identifies candidates, and sends them out to show through tail -f.

But then you may well have daemon processes that don't get called often; it's not clear to me that CPU time alone is a good measure.

That's the point about defining what you really want to do: there's probably a way to do it, but I can't think of a combination of ps flags alone that will do it.

Charlie Martin
@Charlie: Good point! I cannot see anyway to find such processes which I have not used for a long time and which I do not need.
Masi
Is it possible to look at the accumulated processor time and kind of get a feeling if it has run or not?
ojblass
yeah, that was my first thought. See the update.
Charlie Martin
I think maybe you might only need to keep the output of the last tail command to see if something changes... either way you are a genius in my book. :D
ojblass
Oh God, the pressure.
Charlie Martin
Oh, @oj, look at tail -f ... it updates the screen continuously with output. Very nifty.
Charlie Martin
@Charlie: Thank you for the piece of information!
Masi