Operating System - HP-UX
1753876 Members
7690 Online
108809 Solutions
New Discussion юеВ

Re: how to kill all the process

 
unixguy_1
Regular Advisor

how to kill all the process

Test is the one user, there are 100 process running under this user.

how we can kill all the process at a time?
how we can identify the parent process?

how we can close the multiple session in HP-UX.
below are the login session for this "test" user.
-------------------
User tty login@ idle JCPU PCPU what
test pts/ta 10:50am 1:08 -ksh
test pts/tb 1:18pm 30 -ksh
test pts/tc 1:19pm -ksh
test pts/td 1:44pm more -s
---------------

how we can these session at a time?

please help on this . thanks in advance
8 REPLIES 8
James R. Ferguson
Acclaimed Contributor

Re: how to kill all the process

Hi:

The 'ppid' of a process is its parent pid.

If you wanted to find all processes belonging to a user (e.g. "unixguy") you can do:

# UNIX95= ps -u unixguy -o pid,ppid,comm

Notice that there is a space without any semicolon after "UNIX95=" before the 'ps' command. This sets the XPG4 (or 'UNIX95') behavior only for the duration of the command line since setting it can have side-effects for other commands that you may not want or know.

Now if you wanted to kill all of these do:

PIDS=$(UNIX95= ps -u unixguy -opid=)
for HOW in 1 15 9
do
kill -${HOW}
sleep 2
done

Never begin with a 'kill -9' since it cannot be trapped by a process and thus the process has no chance to cleanup temporary files or remove shared memory segments. Instead, use an escalating series of hammers.

Regards!

...JRF...
Victor Fridyev
Honored Contributor

Re: how to kill all the process

>ps -fu username | awk 'NR>1{system("kill " $2)}'
In some secomds:
>ps -fu username | awk 'NR>1{system("kill -9 " $2)}'

HTH
Entities are not to be multiplied beyond necessity - RTFM
OldSchool
Honored Contributor

Re: how to kill all the process

JFF said:
"PIDS=$(UNIX95= ps -u unixguy -opid=)
for HOW in 1 15 9
do
kill -${HOW}
sleep 2
done"

maybe I missed something here, but how is the PID getting to the kill command??
James R. Ferguson
Acclaimed Contributor

Re: how to kill all the process

Hi:

Oops! [ Thanks, OldSchool ]. The suggested code should look like:

PIDS=$(UNIX95= ps -u unixguy -opid=)
for HOW in 1 15 9
do
kill -${HOW} ${PIDS}
sleep 2
done

...I forgot to use the list I created!

Regards!

...JRF...
D. Jackson_1
Honored Contributor

Re: how to kill all the process

reboot... :)
AVV
Super Advisor

Re: how to kill all the process

Hi,


You can kill the ppid of the user.
Michael Steele_2
Honored Contributor

Re: how to kill all the process

man 'killall', used during shutdown.
Support Fatherhood - Stop Family Law
Sagar Sirdesai
Trusted Contributor

Re: how to kill all the process

Hi
fuser -ck