title: Preferred location for PID file of system daemon run as non-root user
body: <p>My question is related to <a href="https://stackoverflow.com/questions/3957242/storing-pid-file-for-a-daemon-run-as-user">this question</a>, but the processes in question are run from cron, and by non-root users.  As such, many of the users don't really have home dirs (or their home dirs point to <code>/usr/share/package_name</code> which is not an ideal location for a PID file).</p>
  
  <p>Storing in <code>/var/run</code> is problematic, because this directory is not writable except by root.</p>
  
  <p>I could use <code>/tmp</code>, but I wonder if this is ideal for security reasons.</p>
  
  <p>I could arrange for a startup script to create a directory in <code>/var/run</code> which is owned by the appropriate user (I can't do this at package install time, as <code>/var</code> is often mounted as tmpfs, so is not persistent).</p>
  
  <p>What's the best practice here?</p>