Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
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

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))
doneelse
print "Usage: $0 process_name"
print ""
fi

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???????????

![]() |
![]() |
![]() |

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