Continuation from #2160. The cleanfs script checks if files are older than /proc before removing them /var/run and /var/lock. However, /proc is mounted before the system clock is synced from the hardware clock in the clock script. This can cause the modification time of /proc to be inaccurate, especially when the hardware clock is in localtime and the time on /proc will be the offset from UTC.
This can cause files in /var to be from a previous boot to appear to be newer than /proc, and they will not be removed by cleanfs. For either pid or lock files, you will have stale files which confuse the other bootscripts.
There are two possible solutions:
1. Don't use a marker file at all. I noticed that on Fedora they just reap everything in /var/run and /var/lock during sysinit. One drawback would be that no processes could write to those directories before cleanfs, but that shouldn't be a problem if cleanfs is ordered right after mountfs. Since /var isn't guaranteed to be mounted until mountfs, you wouldn't lose anything.
2. Choose a different marker file. I think that /etc/mtab is a good candidate. Again, if you put cleanfs right after mountfs, that's the first time /var is guaranteed to be writable. And /etc/mtab is updated during mountfs, so you would be sure that everything older than mtab is from a previous boot. However, if you run cleanfs sometime after boot, that's criteria is probably not accurate anymore.
I'd personally rather go with 1.