RE: How to make sure that the target file to read is not under writing by others?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



-----Original Message-----
From: Ashley Sheridan [mailto:ash@xxxxxxxxxxxxxxxxxxxx] 
Sent: 19 August 2009 11:57 AM
To: arno@xxxxxxxxxxxxxx
Cc: 'Dengxule'; 'Php Maillist'
Subject: RE:  How to make sure that the target file to read is not
under writing by others?

On Wed, 2009-08-19 at 11:55 +0200, Arno Kuhl wrote:
> -----Original Message-----
> From: Dengxule [mailto:dengxule@xxxxxxxxx]
> Sent: 19 August 2009 09:56 AM
> To: Php Maillist
> Subject:  How to make sure that the target file to read is not 
> under writing by others?
> 
> Hi everyone:
> 
> I have a crontab command to execuate my php-script every half an hour.
> 
> The mission of the php-script is to open a file(log file), examine it.
> 
> The target file(log file) is transported to local every half an hour.
> 
> I've no idea how much time it will costs and on the other hand, i want 
> to make sure the file i'm openning is Completely Written.
> 
> Any instruction will be grateful.
> 
> 
> PS: I've made a test. My php-script just "fopen" a local file being 
> transported in, and the "fopen" returns no FALSE value but a resource.
> 
> 
> Dengxule
> 2009/08/19
> ----------------
> 
> Check the timestamp of the log file. Alternatively you can have a log 
> control file that is updated by the program transferring the log file 
> only when the transfer is completed, and work on that.
> 
> Cheers
> Arno
> 
> 
The log control file wouldn't work, as how would you know when to open the
control file?!

Thanks,
Ash
http://www.ashleysheridan.co.uk

----------

You can open the control file any time you want. The info in the control
file tells you whether to proceed. The transfer program adds the entry when
the log has been transferred, the processing script updates the entry to
indicate it's been processed. You can either add a new entry each time
(useful for monitoring to fine-tune the timing, or for keeping a history) or
work on a single entry that's overwritten each time the log is transferred.

Cheers
Arno


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux