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.
Need script to kill process of esdemo,eslm,mfds
Hi,
Can any1 help me to get the scipt for killing process of esdemo, eslm, fds i.e microfocus in linux
we generally use-
ps -ef | grep -i esdemo
ps -ef | grep eslm
ps -ef | grep mfds
Sandeep
simple ways
simpler ways I found...
or direct one liner...
Cheerzz
Joviano Dias
jovistruck@yahoo.com
Goa - India
may not always work
I tried to use your code in a script I wrote today and ran into a problem.
When `ps ax` prints something like this:
your script cuts the first line to "" or " " and the second line to "10025", thus not killing the first process.
I fixed this problem by using the following code:
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.