Rakesh wrote:
abhilash kumar wrote:

Helllo:
I am trying to write a shell script to get the process
id of a particular process (slapd)
and then kill that using 'kill -9 $pid'.

I can get the pid by using prid= pidof slapd
An echo of this for testing gives me the pid number
followed by a blank line and then the prompt.


Now the problem is when I am trying to use this variable in various forms in the shell script and get errors.

option 1:
kill -9 $prid

Output:
20685
kill: usage: kill [-s sigspec | -n signum | -sigspec]
[pid | job]... or kill -l [sigspec]

=========================
Option 2:
actual= "kill -9 $prid"
echo $actual

Output:
20685
./testscript: line 4: kill -9 : command not found

==========================

Option 3:
actual="kill -9 $prid"
echo $actual

Output:
20685
kill -9
#The process is still running.

Can you shed some light on where I am going wrong?
Thank you very much. All help appreciated.

****************************************
Try $pkill <process-name>

Abhilash




Try using this command.

ps auxwww | grep slapd | awk '{print $2}' | xargs kill -9

After awk its single quotes.

Rakesh


killall -9 slapd

Amitay.

--
http://mm.ilug-bom.org.in/mailman/listinfo/linuxers

Reply via email to