Reply to Re: flock and file(myfile.txt)

Your name:

Reply:


Posted by deko on 09/07/06 21:48

> If I want to use file(myfile.txt) and myfile.txt gets written to (flocked)
> frequently, what is the best approach?
>
> Should I try to get a lock on myfile.txt before using file(myfile.txt)?
>
> What I'm thinking is something like this:
>
> try a few times to pull the file into an array
>
> if you can, then do this
>
> if not, die
>
> Other ideas?
>
> Thanks in advance.

How about this:

$myfile = "/path/to/myfile.txt";
$timeout = 0;
while ($timeout < 10)
{
if ($myarray = file($myfile))
{
break;
}
else
{
usleep(100000);
}
$timeout++;
}

Is this the right way to test file(myfile) ??

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация