title: Trying to kill process by shell scripting
body: <p>I want to kill process through shell scripting it is giving me error. Here is what i tried so far:</p>
  
  <p>When i try to kill memcache it give me error like "kill: No such process" , i used below command:</p>
  
  <pre><code>ps -ef | grep "memcache" | awk '{print $2}' | xargs kill; 
  </code></pre>
  
  <p>or if try like below:</p>
  
  <pre><code>kill -9 $(pidof memcache)
  </code></pre>
  
  <p>i get error like below:": arguments must be process or job IDs"</p>
  
  <p>When i run directly on command prompt process is running:</p>
  
  <pre><code>ring@ubuntu:~/parasol$ ps aux | grep memcache     
  memcache   873  0.0  0.0 323220  1188 ?        Sl   22:56   0:00 /usr/bin/memcached -m 64 -p 11211 -u memcache -l 127.0.0.1
  ring      1714  0.0  0.0   9384   920 pts/0    S+   23:45   0:00 grep --color=auto memcache
  </code></pre>
  
  <p>I reff to <a href="https://askubuntu.com/questions/239923/shell-script-to-9-kill-based-on-name">https://askubuntu.com/questions/239923/shell-script-to-9-kill-based-on-name</a>
  AND
  <a href="https://stackoverflow.com/questions/13910087/shell-script-to-capture-process-id-and-kill-it-if-exist">Shell script to capture Process ID and kill it if exist</a></p>
  
  <p>My Ubuntu Version:</p>
  
  <pre><code>DISTRIB_ID=Ubuntu
  DISTRIB_RELEASE=12.04
  DISTRIB_CODENAME=precise
  DISTRIB_DESCRIPTION="Ubuntu 12.04.2 LTS"
  NAME="Ubuntu"
  VERSION="12.04.2 LTS, Precise Pangolin"
  ID=ubuntu
  ID_LIKE=debian
  PRETTY_NAME="Ubuntu precise (12.04.2 LTS)"
  VERSION_ID="12.04"
  </code></pre>