title: Shell Script to Kill a java process - Not working
body: <p>My shell script which I wrote to find the process and kill it is not working . I have tried all the posts in stackoverflow but none worked out for me </p>
  
  <p>Script is as below :</p>
  
  <pre><code> pid=`ps aux|grep 'java -server -Xmx512M -jar -Dsolr.solr.home=. start.jar' | grep -v grep | awk '{print $2}'`
  echo Stopping Solr Server with PID $pid
  kill $pid
  </code></pre>
  
  <p>Issue here is that while echo gives the proper PID say 12345
  but kill throws an error </p>
  
  <pre><code>: arguments must be process or job IDs45
  </code></pre>
  
  <p>I do not understand why only last two digits of PID is being passed to kill?</p>