Operating System - HP-UX
1756924 Members
3749 Online
108857 Solutions
New Discussion юеВ

Re: killing login session

 
SOLVED
Go to solution
Arunvijai_4
Honored Contributor

Re: killing login session

To kill defunt processes for a user, you can use this script

kill -9 `ps -ef|grep $LOGNAME|grep -v grep| defunct|awk '{print $2}'`

-Arun
"A ship in the harbor is safe, but that is not what ships are built for"
Shivkumar
Super Advisor

Re: killing login session

Respected Sirs,

Thanks everyone for your help.

One thing is not clear. As shown in my post above, who command shows more sessions but ps -ef|grep sksonkar shows fewer sessions.
Using kill command i can kill only those sessions who are visible using ps -ef|grep sksonkar command.

What is the easiest way to clean all the sessions which are showing up using who or who -u|grep sksonkar command ?

Thanks,
Shiv
Cem Tugrul
Esteemed Contributor

Re: killing login session

Hi Shiv,

the use of xargs with the kill command


to kill off all processes associated with "ptc":

ps -ef | grep ptc | xargs kill -9 `awk '{print $2 }'`



to kill off all processes associated with "oli":

ps -ef | grep oli | xargs kill -9 `awk '{print $2 }'`



to kill off all processes associated with "etscape":

ps -ef | grep etscape | xargs kill -9 `awk '{print $2 }'`

Good Luck,
Our greatest duty in this life is to help others. And please, if you can't
Yogeeraj_1
Honored Contributor

Re: killing login session

hi again,

if you see man who:


The who command can list the user's name, terminal line, login time, elapsed time since input activity occurred on the line, the user's host name, and the process-ID of the command interpreter (shell) for each current system user. It examines the /etc/utmp file to obtain its information. If file is given, that file is examined. Usually, file is /var/adm/wtmp, which contains a history of all of the logins since the file was last created.



so you should start with trimming the /etc/utmp file...

hope this helps!

kind regards
yogeeraj
No person was ever honoured for what he received. Honour has been the reward for what he gave (clavin coolidge)
Arunvijai_4
Honored Contributor

Re: killing login session

Hi Shiv, Have a look at this thread,

http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=574109

-Arun
"A ship in the harbor is safe, but that is not what ships are built for"
Bill Hassell
Honored Contributor

Re: killing login session

The simplest method is to reboot and the /etc/utmp file will be rebuilt. This file is binary so direct editing with vi is not possible. The fwttmp program can decode and re-encode the utmp file but it is quite obtuse in usage. It requires creating an ASCII version of the file, then manually editing this file, and replacing /etc/utmp with the result. If not done correctly, utmp may become totally corrupted or empty and utiloities (like who) will no longer work.


Bill Hassell, sysadmin
Arturo Galbiati
Esteemed Contributor

Re: killing login session

Hi,
who -Hu|awk '/sksonkar/ {print "kill " $7}'|sh

This command will kill all the pid showed by who command for user sksonkar.
HTH,
Art
John Jimenez
Super Advisor

Re: killing login session

Bill is right. A couple of times I have ran into 1 or two of these users showing up in who but cannot grep it. Lets take of of the ones that are not showing up, lets say for instance
sksonkar ttyqf Sep 26 19:51

What happens when you try to grep ttyqf?
ps -ef | grep ttyqf

If nothing shows up, like Bill said you are going to have to reboot and it will clear it up.

Like I said I have only seen this twice. These 2 occasions happened within on a couple of months apart, but with different seperate users and not myself and not so many of them like you. I was never able to figrue out what happened, only that it has stopped. On your system, you are the one with issues, I am curious to see if you can figure how happens

Hustle Makes things happen
Shivkumar
Super Advisor

Re: killing login session

Thanks Bill!! I respect many Unix gurus like you on this forum.

After joining this forum i came to know how little unix i know.

Regards,
Shiv
CV REDDY
New Member

Re: killing login session

Hi Shiv,
i want to take hp ux m/c archive to store in network pc using net_recover , pls give me some description on that.