1827690 Members
3686 Online
109967 Solutions
New Discussion

Re: during copy

 
Tonatiuh
Super Advisor

during copy

Red Hat Enterprise Linux 3.0 update 4.

What happend in the internals of O.S. during a copy of a file?

I want to put to work a crontab process to copy a file into another file every X seconds. This is:

FILE1 and FILE2 are copied alternatively to FILEPROD every 5 seconds. Second 5 FILE1->FILEPROD, second 10 FILE2->FILEPROD and so on.

What happend with an application which try to access this file to read during the moment of the copy? Is the state of the file locked during the copy and the program just needs to re-tray? or what happend?


3 REPLIES 3
NiCK_76
Respected Contributor

Re: during copy

Hi Tonatiuh ,

Show your crontab for me to solve the problem.

NiCK
just for fun
Vitaly Karasik_1
Honored Contributor

Re: during copy

AFAIK, there is no problem to read file during copying, you will get *old* version of file.

BTW, check "rsync" as replacement for copy.
Thomas Bianco
Honored Contributor

Re: during copy

unix file locks are very good this way. unix and linux only maintain locks for the actual second you're writing data, where as windows will* maintain locks for the entire time the file handle is open.

*generally, the actual file handling depends on the API's in use, and the programers declination. unix programs CAN lock files for indeterminate times, and windows programs CAN release locks quickly.

recently microsoft has been encouraging developers to release file locks in a more timly fashion, the .net APIs include TONS of file access routeens that release locks almost instantly.
There have been Innumerable people who have helped me. Of course, I've managed to piss most of them off.