I have a requirement where I write regular data from Mysql to an output folder using
select * into outfile 'filename' from table...
I have a cronjob written in php which reads these files and upload to a backup.
My worry is that it might not try to read a file which is still being written by MySql.
My question is:
1)Is it possible at first place? 2)Can we use some locking mechanism in this case and if yes which one. I am solvi开发者_C百科ng the issue where data is written by another files using flock.Thanks
The file locking should be handled by the OS. E.G - if mysql has opened the file for writing, and you attempt to open it for writing from PHP, you should be denied access. However, in some systems, you should be able to open the file as read only still.
$fh = fopen($file,'r');
精彩评论