>What would happen if PHP script tried to read a .txt file from disk but
a cron job is concurrently modifying the same .txt file ?
I'm going to use Linux.
If you don't use some form of locking, sooner or later you're going
to read crap out of the .txt file. Generally, all users of the
file have to cooperate with the locking.
A simple form of updating by the cron job: write the modified
version of the file under a different name in the same directory.
Rename it into place, deleting the original file. Readers see the
old version or the new one: never a nonexistent file, never a
half-modified file. This falls apart, however, when the cron job
runs overtime and a second instance of it starts modifying the file
before the first is finished. Also, the readers have to close their
file descriptor and re-open it to see any changes.
Gordon L. Burditt