How to get the idle time in Unix

February 9, 2011 at 23:22:33
Specs: UNIX
Can any one teach me how to get the idle time for each process in Unix?

Thanks You.


See More: How to get the idle time in Unix

Report •

#1
February 10, 2011 at 18:03:44
If the process is attached to a tty, then type:

w

You'll see a column that has idle time.


Report •

#2
February 10, 2011 at 18:34:02
Hi thepubba1,

Thanks for your reply.

The process that i want to look for idle time is not attach to TTY.

Because when i use w, it can't show the process.

I had try many command like who and ps also can't get the idle time for the process that i look for.

Do you have any idea, which command can i use?

Thanks You.


Report •

#3
February 14, 2011 at 20:40:49
I don't think you are going to get this information via a shell script. The reason is that there is no method for getting the necessary information via a review of the process table (ps command). Additionally, if you could successfully cull this information, what exactly are you looking for? Remember, modern operating systems support threads and you'd need to know exactly what they are doing. Since threads have spin locks, you really couldn't tell if the thread is doing work or not. Then, there is the issue of killing what appears to be an idle process and it is not a process you want to kill.

I'd be very careful trying to monitor processes that are not attached to a tty. You could end up causing more problems than you could ever hope to solve if you kill the wrong process.


Report •
Related Solutions


Ask Question