1844880 Members
2140 Online
110233 Solutions
New Discussion

kill old user

 
bishu_1312yahoo.com
New Member

kill old user

hi
In my HP-UX server machine i have some old user which i cannt kill. please tell me how can i delete those. here is as example :

jarhadta pts/22 Feb 15 00:50 old 9540 10.236.0.207

here jarhadta is an ldap user and i want to kill this process 9540 which status is old.
9 REPLIES 9
Jeeshan
Honored Contributor

Re: kill old user

use this

ps -ef|grep $1|grep user| awk '{ print $2; }'|xargs kill -9
a warrior never quits
Kapil Jha
Honored Contributor

Re: kill old user

just check
ps -elf|grep 9540
check what is the status of process
S/U/R
if U u can not kill it , reboot is the only option.
else simply kill -9 9540.
Please tell if u facing sm error.
BR,
kapil
I am in this small bowl, I wane see the real world......
Biswagit
New Member

Re: kill old user

The output is
"$ ps -elf | grep 9540
1 S sysop 2711 19455 1 154 20 c0e72700 23 f8d021b6 12:30:11 pts/3 0:00 grep 9540"



I tried by kill -9 command but failed to kill. please tell me the solution
Kapil Jha
Honored Contributor

Re: kill old user

$ ps -elf | grep 9540
1 S sysop 2711 19455 1 154 20 c0e72700 23 f8d021b6 12:30:11 pts/3 0:00 grep 9540"


are you user sysop???
because from this I can see there is no process like 9450.
Its already killed I suppose this line is for the command u fired ie grep

BR,
Kapil
I am in this small bowl, I wane see the real world......
Biswagit
New Member

Re: kill old user

i m sysop user and jarhadta is a ldap user and i want to kill jarhadta user which status shows old. actually first i login as jarhadta (ldap user) then su to sysop user.

** what does status old mean?

Please give me solution.
Aashique
Honored Contributor

Re: kill old user

Hi Bishu,
The user you are talking is dead user. Coz u will not find the user in the command "ps -ef|grep jarhadta" it will not show you anything.coz the user connected through LDAP.
and only when you used "w" command that time you will see the user.
So the output comes from file /var/adm/btmp.
So one way is flash the file.

Thanks & Regards

Aashique
Shibin_2
Honored Contributor

Re: kill old user

Hi,

Do you want to kill the user or the process belongs to the user ?

If you want to kill the process belongs to the user, use, ps -ef command.

If you want to kill the user, use who -u command to find the user and kill him. Whatever the processes belongs to the user, will terminate, once you kill the original user.

Thanks
Regards
Shibin
Bill Hassell
Honored Contributor

Re: kill old user

The output line is from who -u and the man page is helpful:

"-u Lists only those users who are currently logged in. name is the user's login name. line is the name of the line as found in the directory /dev. The time field indicates when the user logged in. activity is the number of hours and minutes since input activity last occurred on that particular line. A dot (.) indicates that the terminal has seen activity in the last minute and is therefore ``current''. If more than twenty-four hours have elapsed or the line has not been used since boot time, the entry is marked old. This field is useful when trying to determine whether a person is working at the terminal or not."

> ** what does status old mean?

The user has been logged in but no terminal activity for more than 24 hours.

> kill -9 .. doesn't work

That is quite normal for a process that is hung on an I/O (almost always networking) that will never complete. kill doesn't actually stop a program. Instead, it sets a flag (a signal) in the program's process table and the next moment that the program starts running again, the signal will be processed. All signals except -9 can be handled (trapped) by a program. For kill -9, the program will terminate unconditionally when the program starts the next instruction.

So until the process (9540) completes the I/O, it will hang forever. NOTE: it consumes no resources in the system. There is an entry in the process table but it has been suspended. So ignore the process and the associated user.

> ps -elf | grep 9540
> ps -ef|grep $1|grep user| awk '{ print $2; }'|xargs kill -9

Please, don't use grep with ps!!! The first example will find PID 9540 but also find PID 19540 and command line values such as abc9540zz or index:195400. If you kill everything returned by this grep, you'll break unrelated processes. You will get an EXACT match with ps. The man page is very helpful:

ps -lfp 9540

ps reads the process table knows exactly which process is 9540.

The second example is even more dangerous as it uses grep for a particular user but it will find the user's ID in many different locations on the line -- grep has no concept of a field or column. Again, ps knows exactly how to find a specific user:

ps -flu jarhadta

But remember that ps will find all processes owned by that user ID. As mentioned, there are other processes owned by this user that are not to be terminated.

But there are also many other unused options for ps, specifically -H, -C and -o. -H shows processes sorted and indented based on hierarchy, so each process tree can be seen. -C matches an exact process name (no grep), and -o eliminates the need for awk to parse the line by showing just the desired fields. NOTE: all of these options require temporary setting of the UNIX95 variable so to find all sh processes use this (exactly as shown):

UNIX95=1 ps -fC sh

compare that with:

ps -ef | grep sh

Lots of mistakes with grep...

Also try this:

UNIX95=1 ps -efH

shows all processes sorted by hierarchy (parent - child). You can combine _H with other selections like user ID:

UNIX95=1 ps -fHu billh


Bill Hassell, sysadmin
Kapil Jha
Honored Contributor

Re: kill old user

can u please check
ps -elf|grep 9450|grep -v grep
I think u wont find anything.......

pls send output of
who -u |grep

BR,
Kapil
I am in this small bowl, I wane see the real world......