title: Trying to write a script to kill a program automatically (mac/unix - kill tomcat)
body: <p>by hand, here is the process:</p>
  
  <pre><code>ps -ef | grep tomcat
  </code></pre>
  
  <p>The results of this look like:</p>
  
  <p><code>0 39107     1   0  5:40PM ttys004    5:22.34 /System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK/Home/bin/java -Djava.util.logging.config.file=/opt/local/tomcat7/conf/logging.properties -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -server -Xms384m -Xmx768m -XX:NewSize=256m -XX:NewRatio=2 -XX:PermSize=128m -XX:MaxPermSize=384m -XX:+UseParNewGC -XX:+UseConcMarkSweepGC -XX:+CMSIncrementalMode -XX:+CMSIncrementalPacing -XX:+CMSClassUnloadingEnabled -Dsun.rmi.dgc.client.gcInterval=3600000 -Dsun.rmi.dgc.server.gcInterval=3600000 -Djava.endorsed.dirs=/opt/local/tomcat7/endorsed -classpath /opt/local/tomcat7/bin/bootstrap.jar:/opt/local/tomcat7/bin/tomcat-juli.jar -Dcatalina.base=/opt/local/tomcat7 -Dcatalina.home=/opt/local/tomcat7 -Djava.io.tmpdir=/opt/local/tomcat7/temp org.apache.catalina.startup.Bootstrap start</code></p>
  
  <p>the second number is the pid.</p>
  
  <p>Then I do</p>
  
  <pre><code>sudo kill tomcat_pid
  </code></pre>
  
  <p>How can I automate this?</p>
  
  <p>ps. I know there is a shutdown.sh script. I've tried it but it never works.</p>