In *nix the "kill" command needs to know the pid(process id) of the process to kill it. So i decided to code a bash script to kill a process by name :
#!/bin/bash
if [ $1 -eq ""]; then
echo "Usage : ./pkill.sh <process name>"
else
get_proc=`ps -e -o pid,command | grep $1`
echo $get_proc > get_it
get_pid=`gawk -F" " '{ print $1 }' get_it`
kill -9 $get_pid
fi
The script is quite messy and certainly needs more improvement.












simple ways
simpler ways I found...
or direct one liner...
Cheerzz
Joviano Dias
jovistruck@yahoo.com
Goa - India
code brackets
Himanshu,
Use the "[" and "]" for the opening and closing square code brackets, "<" and ">" for the angle brackets. Also enclose scripts with <pre> tag. Thanks for your informative posts
--
Sandip
Sandeep bro, Thanks. I
Sandeep bro,
Thanks. I will keep that in mind while posting code from now on.
Post new comment