I have a small PHP script I wrote to help me push changes from staging to production. I run both staging and prod on the same server so my script copies changes from staging folders to prod folder.

This has been working fine until today when I had a few instances when files were only partially copied over resulting in some down time. I'm wondering if a user accessing a Web page using a file being copied at the exact same time resulted in an interruption of the cp command and a partial file copy. Any ideas or solutions?

The copy command is basically:

exec( 'cp -Rfpuv /staging/folder/path /prod/folder/path' );

The server is a basic LAMP stack, with Apache 2, PHP 5, MySQL 5 and CentOS 5.


No. Reads would not affect writes.

+1  A: 

You could try rsync as well.