Does anyone know how do you determine the user idle time of stdin in order to log the user out for being idle too long. I would like to write a c program to do this but I it is not clear upon how to determine idle time from keyboard input.
I am aware of this command along with the who command, I have looked at the source for these files and they use the time now-last access of tty, I would like to determine idle time by using stdin somehow. Also, Id like to be gangster and write it in C.
At least on my system, the mod time on the tty's device seems to be where this information is coming from. If it works the same on your system, you can use that.
I type on the keyboard and it writes to the terminal, but the last access time to stdin or the specific tty are not reflected by my typing. So I have no way to test my program.
Does this make sense? Perhaps I am thinking about this wrong. Sorry for double posting.
Then I started typing in another window, which is connected to /dev/pts/1. The time stamp changed immediately, although then -- the granularity being only one minute in the ls -l output -- seemed stuck. Tried again after the minute changed, and again, it updated basically immediately.
You pause in a program which is running on the terminal you are watching? You want to catch input even when the tty is not actually responding? If I run sleep 600 and then type in something during that time, the tty time stamp does not update. But that would seem to pretty much match a reasonable definition of "idle", from the system's perspective, although certainly from the user's perspective, if you are typoing (oops) at it, you are not idle.
If you pwn the system (I guess you do) then I suppose you could attach a kernel module to the tty driver or something ... sounds like too much work.
Last edited by era; 04-07-2008 at 03:11 PM..
Reason: Philosophical remarks on "idle"
I want to get average idle time of the server using mpstat. The problem I am having is %idle is not in same columns in all the versions of linux.
example 1:
example 2:
I tried below command as generalized solution but as Average as one less column output is not proper.
I am... (1 Reply)
Hello..
I have many sleepy users on my Solaris box and need to kill them if they are idle for more than 45 minutes for example...I know who -u gives and the idle time but unable to make a awk line to get the condition perfect. Please help...:wall: (9 Replies)
Folks,
I have written one script for following condition by referring some of online post in this forum. Please correct it if I'm missing something in it. (OS: AIX 5.3)
List the idle user. (I used whoidle command to list first 15 user and get username, idle time, pid and login time).... (4 Replies)
Hi All,
I am having a problem where my mouse (USB) is freezing after some idle time, and I am having to reboot everytime that happens.
I looked in the file /etc/X11/xorg.config to see if there is an entry for mouse and I could not find it. Instead I found the following entry:
Section... (8 Replies)
I need to find the idle time on a machine in the manner: How long time ago somebody did the last action with mouse or keyboard? Unfortunately "w" doesn't do this. It produced the following output on a machine a user was actually working on with an application:
15# w
15:55:28 up 15 days, ... (1 Reply)
HP-UX B.11.23 ia64
Hi everyone,
First of all I am new member to this forum. Thankyou all for this forum, it helped me many times.
Coming to my question,I am writing a C program to find the log info of the users who are currently logged in(precisely what who -u do).
I am able to get... (0 Replies)
Hi All
I need to find the idle time of a user... but my OS seems to be not supporting finger
$ finger
-sh: finger: command not found
I need to find the idle time and perform some other operations... So is there any other way i can find the idle time of a user...
$ uname -a... (2 Replies)
Since yesterday the vmstat command is displaying the cpu idle time at 100%At each time interval. It never changes. Not sure what it means other than it Quit calculating that stat. And I'm curious why. Using sar I can display a correctCpu idle percent, but vmstat does not. Any ideas why or... (2 Replies)
Matez,
I have a list of process id's in a text file. I want to know how to find the idle time of a process which are more than 300secs and kill them accordingly.
Could you please help me to get these details. I want to write a shell script with this.
Thanks..Krish :) (36 Replies)