General
cancel
Showing results for 
Search instead for 
Did you mean: 

How do you kill a hung Unix session?

SOLVED
Go to solution
Mary Claire Pollard
Occasional Advisor

How do you kill a hung Unix session?

I have some users logged into a server (HP-UX 11) - but their sessions aren't really open. This has been caused by the same user locking themselves by logging into the web console and the console. Both sessions say "locked by [user]". The other couple may have exited the session incorrectly? "X"ing out of the terminal emulator and leaving the session hung?

I can see these sessions from "finger" and "who". How do I kill the sessions?

Thanks!
Mary P.
7 REPLIES
fg_1
Trusted Contributor

Re: How do you kill a hung Unix session?

Mary, Kill -9 on the ppid of the user.
James R. Ferguson
Acclaimed Contributor

Re: How do you kill a hung Unix session?

Hi Mary:

Don't start with a 'kill -9'. This isn't trappable and doesn't give a process any chance to cleanup memory and/or temporary files.

Try a kill like:

# kill -hup
# kill -term

...and as a last resort:

# kill -9

Regards!

...JRF...
Mary Claire Pollard
Occasional Advisor

Re: How do you kill a hung Unix session?

That is the weird thing. I can see them from who and finger, but when doing ps -ef | grep [user] there is nothing associated with the logins. Very odd?
John Payne_2
Honored Contributor

Re: How do you kill a hung Unix session?

You may be able to do a 'ps -ef |grep ' and see if the user has a shell sitting open. If so, kill the shell session, and that should do it.

Hope it helps

John
Spoon!!!!
John Poff
Honored Contributor
Solution

Re: How do you kill a hung Unix session?

Hi,

A couple of tricks with the 'ps' command:

If you want to see the processes for a certain user, you can do:

ps -fu jpoff

will show all of my processes.

If you want to see all the processes associated with a certain tty, try this:

ps -ft ttyp1

will show all the processes associated with the ttyp1 port. It saves you having to grep for what you are looking for.


To kill the user processes, once you find them, I usually start with a kill -15 PID. If that doesn't work, I usually have pretty good luck sometimes with a kill -2 PID.

As James has mentioned, the kill -9 is the last resort. It will kill the process but it will leave open any files or memory the process was using, which might leave you with the same problem you had when the process was running.

JP
Mary Claire Pollard
Occasional Advisor

Re: How do you kill a hung Unix session?

Ah, ttyp...not username. Worked! Thanks!

-Mary P.
James Odak
Valued Contributor

Re: How do you kill a hung Unix session?

when you list the who entry
grep the tty port thay are conected to with your ps -ef|grep ttyp1 or whatever it may be and kill those PIDs
this should clear any process the user started

g'luck