my system is Ubuntu 10
here is my code:
#!/bin/bash
pid = `ps -ef | grep process_string | /usr/bin/awk '{print $2}'`
`kill -9 $pid`
pid is the process id of process_string(there is only one matched)
but when I run this sh,I don’t kill the process
how can I solve it?
pidwith arguments of=and the stdout ofps -ef ....kill -9 $pid, you don’t want that.$(...)than backticks.You may want to use
pgrepto get the pid instead, orpkillorkillallto just kill by name directly (be careful with that last one, as the name implies it will kill all instances of the named program).