title: How do I write pid to file
body: <p>I know this could be easy, but I am unable to figure out. 
  We want to run two instances of luigi on one machine so need to modify init.d script to write PID to file rather than just touching empty file.</p>
  
  <pre><code>echo -n $"Starting luigid scheduler as $LUIGID_USER: "
  ( ( /usr/bin/sudo -u $LUIGID_USER $LUIGID_BIN &gt;&gt;/var/log/luigid/server.log 2&gt;&amp;1 ) &amp;)
  RETVAL=$?
  [ $RETVAL -eq 0 ] &amp;&amp; touch /var/lock/subsys/luigid &amp;&amp; echo_success || echo_failure
  echo
  return $RETVAL
  </code></pre>
  
  <p>At present its just touching the empty PID file. I want it to write PID into the file.
  Also while stopping I want to kill by PID stored in PID file</p>
  
  <pre><code>echo -n $"Stopping luigid scheduler: "
  killproc luigid
  RETVAL=$?
  [ $RETVAL -eq 0 ] &amp;&amp; rm -f /var/lock/subsys/luigid &amp;&amp; echo_success || echo_failure
  echo
  </code></pre>
  
  <p>Any help please ?</p>
  
  <p>Thanks</p>