Question

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?

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top