title: Measure Tomcat's Shutdown Interval
body: <p>I am trying to measure my Tomcat server shutdown interval and write it to the log. I'm trying to use the following Python code:</p>
  
  <pre><code>    log_times.append(datetime.now().strftime(TIME_PATTERN)) # logs start time
      subprocess.check_call(['service', 'tomcat7', 'stop'])
      pid = subprocess.Popen(['pgrep', '-utomcat7'], stdout=subprocess.PIPE).communicate()[0]
      while (pid != ''):
          log.info('pgrep found tomcat process: %s', pid)
          pid = subprocess.Popen(['pgrep', '-utomcat7'], stdout=subprocess.PIPE).communicate()[0]
      log_times.append(datetime.now().strftime(TIME_PATTERN)) # logs tomcat shutdown time
  </code></pre>
  
  <p>Is there a better \ accurate way to do this ?</p>