title: linux kill command -9 vs -15
body: <p>I have a process that i would like to kill and then restart a service. Someone has written a code to kill the process by writing the following set of scripts</p>
  
  <pre><code>ps -ef |grep "process_name" | awk '{print "kill -15 " $2}'&gt; /projects/test/kill.sh
  #run the kill script
  /projects/test/kill.sh
  </code></pre>
  
  <p>and then again</p>
  
  <pre><code>ps -ef |grep "process_name" | awk '{print "kill -9 " $2}'&gt; /projects/test/kill.sh
  #run the kill script
  /projects/test/kill.sh
  
  #finally
  service restart command here     
  # the problem here is that service does not restart properly sometimes, 
  as it thinks that process is still running.
  </code></pre>
  
  <p>As i understand kill -15 gracefully kills the process. But then right away they have the kill -9 as well. 
  So if a process was getting killed in the first command, what happens when kill -9 is also run on the same process? Or will the ps -ef even list out that process since it has been marked for kill?</p>
  
  <p>Thanks!   </p>