If the script somehow dies between the truncate and the close command, the file will become empty. Are you by any chance printing something (the value of the counter) between the truncate and the close? If so, the script may die because it gets a SIGPIPE.
In reply to Re: Concurrent file access with flock()
by ambrus
in thread Concurrent file access with flock()
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |