Computing.Net > Forums > Unix > kill processes

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

kill processes

Reply to Message Icon

Name: Wolfgang Maier
Date: December 30, 2002 at 05:36:53 Pacific
OS: Linux Suse 8.0
CPU/Ram: Athlon XP 1500+ / 512
Comment:

Hey there! I'm new to UNIX / Linux and have some problems. I know that I can kill processes in unix, but I don't know how. I know the kill command, but how do I list running processes??? Whats PID ??? Please help. Thx and happy new year.

Wolfgang



Sponsored Link
Ads by Google

Response Number 1
Name: David Perry
Date: December 30, 2002 at 06:20:57 Pacific
Reply:

ps -ef

will output a list of currently running processes. Column 2 of the output is the PID. To kill off a running process, forcefully, execute the command

kill -9 PID ( where PID is an integer you got from the ps command ).

Here is a script I wrote to kill off processes by name

-----------8<----cut here---8<-------
#!/bin/ksh
if [ $# -gt 0 ]; then
process_name=$1
ps_count=`ps -ef | grep -v 'grep' | grep -v 'kill' | grep -i -c $process_name`
echo "Process count: $ps_count"
set -A array_name `ps -ef | grep -i $process_name | grep -v 'grep' | grep -v 'kill' | awk '{print $2}' | sort -u`
print "ps -ef | grep -i $process_name | grep -v 'grep' | grep -v 'kill' | awk '{print \$2 \$8}' | sort -u -n"

print "${array_name[*]}"
kill_count=0
while [ $kill_count -lt $ps_count ]
do
kill -9 ${array_name[$kill_count]}
# print "kill -15 ${array_name[$kill_count]}"
((kill_count=kill_count+1))
done

else
print "Usage: $0 process_name"
print ""
fi


0

Response Number 2
Name: Wolfgang Maier
Date: December 30, 2002 at 06:32:20 Pacific
Reply:

Thanks for the prompt answer. Happy new year.
Wolfgang


0

Response Number 3
Name: Bishal
Date: January 1, 2003 at 22:18:23 Pacific
Reply:

I use kill -9 PID to kill a specific user. It works fine, but when any other user log on the same modem, although he is connected, he cannot browse the net. Mine is dial-in and proxy server where users dial via there telephone lines. I'm using Rocekt ports and external modem. I have to reboot the server to make it work again.

Help me???????????


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Unix Forum Home


Sponsored links

Ads by Google


Results for: kill processes

kill Process www.computing.net/answers/unix/kill-process/6203.html

Killing processes in 'top' www.computing.net/answers/unix/killing-processes-in-top/690.html

Script to kill processes www.computing.net/answers/unix/script-to-kill-processes/6419.html