LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Enterprise (http://www.linuxquestions.org/questions/linux-enterprise-47/)
-   -   Users forget to log off and slow down the server (http://www.linuxquestions.org/questions/linux-enterprise-47/users-forget-to-log-off-and-slow-down-the-server-688623/)

deacon912 12-05-2008 05:08 PM

Users forget to log off and slow down the server
 
Hello,

I am using a using RHEL5 for a server that is accessed remotely. To log in Reflection X or XManager is used. Most users when they are done do not log out, they just turn their computer screen off while still connected to the server. This has been causing some problems recently when the number of logins gets around 50. Is there a way to automatically kill all users (except root) at a specific time of the day or limit the time a session is allowd to exist.

I have been using the kill -9 command to clean out the extra users each morning.

Thank you

TB0ne 12-05-2008 05:24 PM

Quote:

Originally Posted by deacon912 (Post 3365837)
Hello,

I am using a using RHEL5 for a server that is accessed remotely. To log in Reflection X or XManager is used. Most users when they are done do not log out, they just turn their computer screen off while still connected to the server. This has been causing some problems recently when the number of logins gets around 50. Is there a way to automatically kill all users (except root) at a specific time of the day or limit the time a session is allowd to exist.

I have been using the kill -9 command to clean out the extra users each morning.

Thank you

Sure, just have a cron script run a "who -u | grep -v root", should give you just the non-root user names and PID's. Can probably do a one-liner using AWK to just barf out the PID's, and kill them, but don't know that syntax off the top of my head...

Quakeboy02 12-05-2008 06:43 PM

Check into the "timeoutd" package.

rweaver 12-08-2008 03:49 PM

Quote:

Originally Posted by deacon912 (Post 3365837)
Hello,

I am using a using RHEL5 for ...<SNIP>...

Thank you

There are several good solutions available depending on how you want to force the logout exactly.

The most simple solution if your users use bash or korn shell is to set the TMOUT variable in the system wide bashrc.

echo "export TMOUT=3600" >> /etc/bashrc
echo "readonly TMOUT" >> /etc/bashrc

Should work on RHEL4/5, On most debian derivatives you could do the same with the /etc/bash.bashrc file. The number is the number of seconds... a few round and handy useful values 300 (5 minutes), 1800 (30 minutes), 3600 (1 hour), 10800 (3 hours), and 86400 (24 hours). The readonly line prevents the users from altering it once they figure out what is going on.

If the users are SSHing into the system some versions of sshd will allow you to set "IdleTimeout" (unfortunately, most modern versions do not allow this.)

The alternative beyond that point is to use a watchdog program for ssh or a daemon to monitor idle time as suggested by a previous response.

Good luck and I hope it helps!

deacon912 12-31-2008 09:14 AM

Another Solution
 
I found a quick way to kill all processes used by a specific user. The skill -kill -u "username" command works perfectly.

rweaver 12-31-2008 10:14 AM

Quote:

Originally Posted by deacon912 (Post 3392568)
I found a quick way to kill all processes used by a specific user. The skill -kill -u "username" command works perfectly.

Nod, skill is an effective way to kill all their processes. The one thing to be aware of is that skill is also considered depreciated and unsupported. It may or may not be available in the future. On linux you can look into pkill or killall, but don't use the later on most other forms of unix as it does something completely different ;)


All times are GMT -5. The time now is 10:25 AM.