  | |  | Idle ssh users | Idle ssh users 2006-01-26 - By Rick Stevens
Back On Thu, 2006-01-26 at 11:22 -0700, redhat@(protected) wrote: > On occasion we have have people login via ssh to some of our RH linux > systems and they do not log out. When doing a "w" or > "who" we see idle connections for days sometimes. What is the > recommended way to log these users out? Is there a better way than just > killing the users ssh process?
Not really. You can write a script that parses the output of the "last" or "who" commands and kills off the processes involved. For example:
#!/bin/bash PATH=$PATH;/usr/bin;/bin WHOLIST=`who -u` for LINE in $WHOLIST; do echo $LINE | awk '{if (index($6, "old")) system("kill "$7);}' done
would kill any user's login process that had been idle for over a day. I'd set that up as a shell script and run a cron job for it every, oh, four hours or so, depending on what you want to do.
See "info who" for details on the "-u" option.
-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- -- - Rick Stevens, Senior Systems Engineer rstevens@(protected) - - VitalStream, Inc. http://www.vitalstream.com - - - - You know the old saying--any technology sufficiently advanced is - - indistinguishable from a Perl script - - --Programming Perl, 2nd Edition - -- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- --
__ ____ ____ ____ ____ ____ ____ ____ ____ ____ Redhat-install-list mailing list Redhat-install-list@(protected) https://www.redhat.com/mailman/listinfo/redhat-install-list To Unsubscribe Go To ABOVE URL or send a message to: redhat-install-list-request@(protected) Subject: unsubscribe
Earn $52 per hosting referral at Lunarpages.
|
|
 |