1753569 Members
5700 Online
108796 Solutions
New Discussion юеВ

Re: Logout a user

 
SOLVED
Go to solution
Jonathan Caplette
Regular Advisor

Logout a user

Hi guys,

I wanna know how can I logout a user???

I'm logged on a workstation with root vi a rlogin. On that station there's a user who has stay connected and I need to log it out...

Thanks
9 REPLIES 9
Sajid_1
Honored Contributor
Solution

Re: Logout a user

hello,

You can kill that session, if you have the rights to do that. Make sure you are not throwing out somebody who is working now:
# who
# whodo
# ps -aef | grep user_name

get the PID and process lists and issue kill command:
# man kill
# kill -15 (or, -13,5,9 etc)
learn unix ..
Chris Lonergan
Advisor

Re: Logout a user

Find the login process via ps or whodo and kill it

Chris
Kelli Ward
Trusted Contributor

Re: Logout a user

Hi,
You can also find the PID (to kill) through who -u
Good luck,
Kel
The more I learn, the more I realize how much more I have to learn. Isn't it GREAT!
Jonathan Caplette
Regular Advisor

Re: Logout a user

Ok thanks all!!!
Hai Nguyen_1
Honored Contributor

Re: Logout a user

Jonathan,

Please be sure that the user's session is idle. The following command will kill the user's connection which in turn, should terminate all processes spawn within the session.

# kill -9 `who -u | grep | awk '{print $(NF - 1)}'`

Hai
Nick Wickens
Respected Contributor

Re: Logout a user

Always issue the kill command as a "kill -15" (Its actually the default for kill anyway so you can just kill).

Only use the kill -9 as a last resort as you could end up with zombie processes.

Also if the user is connected to a database such as Informix and I guess Oracle its good practice to drop the connection to the database first using the database engines commands. If you are using Informix then let me know on this link and i'll post up my kill script which checks for Informix database connections,logs the SQL, drops the connection and then kills any shell processes with a -15 then waits and if still active will then prompt for an ok to kill -9.
Hats ? We don't need no stinkin' hats !!
Sushil Singh_1
Advisor

Re: Logout a user

Hi there,
To kill the user, just find the user's process ID and then use the kill -9 or 15. You might know to use the 'who' commnad

who -u
kill -9 or kill -15

but what u might not know if that is u use
who -m
this would give u the PID for ur login. So kill every user except the one which come from who -m. I hope this helps

Ian Cameron
Frequent Advisor

Re: Logout a user

I had a user/workstation hung up completely with an application process that I could not kill. I could not reboot the machine because it is a license server for an application and 12 other users. I had nothing to lose at this point so after warning everybody, I rlogin'd and ran:

/sbin/init.d/dtlogin.rc stop

Then:

/sbin/init.d/dtlogin.rc start

I kept an eye on things afterwards and there were no problems. Maybe someone here in the forums knows a reason why this should not be done, all I know is that it worked.

Wodisch_1
Honored Contributor

Re: Logout a user

Hi Jonathan,

I would go for the PID form "who -u" for that user's shell, and for sending SIGHUP (that's no 1), ie.e "kill -1", as that signal is used to tell a process that is has been logged off...

Just my $0.02,
Wodisch