1837007 Members
1961 Online
110111 Solutions
New Discussion

Idle or process running

 
Suvadip De
New Member

Idle or process running

I want to identify whether a terminal is sitting idle or a process is running on the terminal . (both shows idle times when using "w" command)
Please someone help its urgent!!!
Entrepreneurship is the best policy
5 REPLIES 5
Jeff Schussele
Honored Contributor

Re: Idle or process running

Hi Suvadip,

There will always be some processes running even when the system is "isle".

What you need to do is list the processes & search for the process in question. If you know the process_name then do

ps -ef | grep process_name

If you don't know the process name but do know the username then do

ps -ef | grep username

This will list all processes started by username.

HTH,
Jeff
PERSEVERANCE -- Remember, whatever does not kill you only makes you stronger!
Helen French
Honored Contributor

Re: Idle or process running

Hi Suvadip:

Try these commands:

# ps -aef | grep term_name
# whodo
# gpm

HTH,
Shiju
Life is a promise, fulfill it!
Jeffrey Davis_1
Frequent Advisor

Re: Idle or process running

Hi. I agree. Run the following:
ps -t tty?? (for tty in question to get user)
ps -eaf | grep (to get main PID)
ps -eaf | grep
(to get other processes spawned & time active)
harry d brown jr
Honored Contributor

Re: Idle or process running

If you want to log them off after some period of inactivity, providing they are sitting at a shell prompt, put this in the .profile:

readonly TMOUT=300

after 5 minutes of inactivity at a SHELL prompt ONLY, it will log them out!

If they are using anything, like vi, emacs, piping output to more, whatever, they will not be logged out.

live free or die
harry
Live Free or Die
Bill Hassell
Honored Contributor

Re: Idle or process running

Processes and terminal (tty connections) do not necessarily go together. An idle terminal may be a shell waiting for command from the user, which consumes no CPU time. The user may have started several background processes and then logged out which means that the processes are no longer associated with a terminal connection.

So the problem is more complicated than the simple w command can handle. Instead, you'll want to look at processes owned by each user, something like this:

UNIX95= ps -e -o time,ruser,args | sort -r | more

which sorts all the processes by amount of time accumulated. Or you could:

UNIX95= ps -e -o time,ruser,args | grep -v root | sort -r | more

to get rid of all the root processes. Or you could summarize by each user:

UNIX95= ps -e -o time,ruser,args | grep -v root | sort -r | more

Now, knowing which user is accumulating lots of time is not necessarily the best way to eliminate a performance issue unless there is a runaway program...but then it would pop to the top of the above lists.


Bill Hassell, sysadmin