PHP lacks any specific function to fsync on a file AFAIK. I do however feel the urge to fsync a logfile I am appending to from PHP.
Is there any native PHP function known to cause an fsync? Or any workaround?
PHP lacks any specific function to fsync on a file AFAIK. I do however feel the urge to fsync a logfile I am appending to from PHP.
Is there any native PHP function known to cause an fsync? Or any workaround?
If you're dealing with a regular file, closing it with fclose will most likely commit your changes to disk. To assure that log messages hit the disk, just open and close the file for each write to your log.
Writes to the system log should take place immediately and are handled by the OS.
I'm afraid it's not possible. The only reference to fsync
in the sources is in the implementation of the flush
operation for regular filesystem streams and it's just to explicitly say they're not fsyncing, only calling fflush
.
If you really need this, you have to do it in a PHP extension.