-1

Does it mean my distro is broken (it's a custom distro for a board I'm using, it could easily be buggy)? Can I tweak this behaviour?

1

Yes, that sounds broken. The Filesystem Hierarchy Standard mandates that

This directory contains system information data describing the system since it was booted. Files under this directory must be cleared (removed or truncated as appropriate) at the beginning of the boot process.

0

Unless /var/run is a RAM disk, there is no reason that rebooting will affect any of its contents at all. Most well-behaved applications that drop files there will (try to) clean up after themselves, but other than its generalized use-case there is nothing special about that directory on your filesystem as compared to most others.

  • I don't believe that's true. See Ulrich's answer. The contents of /var/run are supposed to be deleted not just due to cooperating well-behaved applications. For instance, cron puts crond.reboot there, and never deletes it, relying on this behaviour of the directory. – user907323 May 21 at 15:47
  • That describes what is supposed to happen in that directory. The only way this can be (nearly) guaranteed to be the case is if it is a RAM disk or other ephemeral filesystem. It is incumbent on applications that write to that location to clean up after themselves. – DopeGhoti May 21 at 17:59
  • You are right about the ephemeral filesystem part. And /var/run should by spec be such. One way to do that is to implment it as a symlink to /run, which is in turn a mount of tmpfs. But no, it's not incumbent on apps to clean after themselves, precisely because the contents should, as per OS spec, disappear on reboot. – user907323 May 22 at 7:39
  • The way I usually think of it as a user/admin is that I can expect that the contents of /tmp shall be removed at shutdown, and that I must not rely on anything in {/var,/run} being there after shutdown. I generally sanity-check anything I read from /var/run' (PID file? Use kill -0` to check that PID actually exists, for instance) just in case it's a stale or orphaned file. – DopeGhoti May 22 at 15:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.