- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- control login
Operating System - Linux
1823366
Members
2756
Online
109654
Solutions
Forums
Categories
Company
Local Language
юдл
back
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Forums
Discussions
юдл
back
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Blogs
Information
Community
Resources
Community Language
Language
Forums
Blogs
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-14-2008 07:37 AM
тАО01-14-2008 07:37 AM
control login
I use linux box , in the system , all user are only allowed one login at the same time , that mean all users can only have one login session in the system at the same time , so sometimes when the user was disconnected by unexpected reason (the reason such as unstable network ) , then the system does not allow the user login again until the pervious login was logged out , so I would like to ask how to do that - when the user login, if it found there is a pervious login session in the system ( or this user's process ) , then logout this login and kill all its process , so that the system release the login to user , then the user can login to the system now , can advise how to do that ? thx in advance.
2 REPLIES 2
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-14-2008 08:02 AM
тАО01-14-2008 08:02 AM
Re: control login
You must consider that if you don't handle this carefully, the user may "forget" that was already logged in and try a second session, killing all its jobs. That is not good.
You will need a script like this in the profile:
SESCOUNT=`who -a | grep $USER | wc -l`
if [ $SESCOUNT -gt 1 ]
then
THISTTY=`tty | sed "s/\/dev\///"`
OLDSHELL=`ps -u $USER | grep -v $THISTTY | awk {'print $1}'`
kill -9 $OLDSHELL
fi
What it does is to check all "bash" process and kill the process not asociated with the current terminal. If you kill the parent shell, all children processes will die.
You will need a script like this in the profile:
SESCOUNT=`who -a | grep $USER | wc -l`
if [ $SESCOUNT -gt 1 ]
then
THISTTY=`tty | sed "s/\/dev\///"`
OLDSHELL=`ps -u $USER | grep -v $THISTTY | awk {'print $1}'`
kill -9 $OLDSHELL
fi
What it does is to check all "bash" process and kill the process not asociated with the current terminal. If you kill the parent shell, all children processes will die.
Por que hacerlo dificil si es posible hacerlo facil? - Why do it the hard way, when you can do it the easy way?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-14-2008 08:25 AM
тАО01-14-2008 08:25 AM
Re: control login
Shalom,
There is nothing built in to Linux to perform this. You have to use the code that Ivan posted or soemthing else.
/etc/profile is the gate where you can do this kind of conditional access.
SEP
There is nothing built in to Linux to perform this. You have to use the code that Ivan posted or soemthing else.
/etc/profile is the gate where you can do this kind of conditional access.
SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
The opinions expressed above are the personal opinions of the authors, not of Hewlett Packard Enterprise. By using this site, you accept the Terms of Use and Rules of Participation.
Company
Learn About
News and Events
Support
© Copyright 2025 Hewlett Packard Enterprise Development LP