Linux - EnterpriseThis forum is for all items relating to using Linux in the Enterprise.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
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.
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...
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!
Last edited by rweaver; 12-08-2008 at 02:58 PM.
Reason: Explain "readonly"
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
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.