RE: [PHP] File locking & cron jobs

From: Date: Fri, 15 Dec 2000 22:05:56 +0000
Subject: RE: [PHP] File locking & cron jobs
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-30593@lists.php.net to get a copy of this message
this may be too round about but you could do the following with PHP filesystem commands: - keep the files to be copied/modified chmod 000 - when one is to be opened to modify, change the chmod to 700 (or whatever you need) (you could code that as well... in short creating a "file checked out" pointer) - have your cron run a PHP script instead of executing CP commands - have the PHP script poll the files for their attribs... copy the files that are 000 and spool the rest... revisit the directory in a minute or two to check the attribs of the spooled files, copy any that are back to 000 and so forth (adding whatever logic/time delays you feel is necessary) - when PHp performs the copy of a file it can chmod 755 it for the web server at that time... kind of round about and may be a little excessive... why not have the editing users download the files that are being edited and uploading them when complete... avoids any problems along this line. tie that in with timestamp checking and it should be pretty foolproof. Just some ideas... again, some insight into the application you are talking about (what type of files/mods) may enable some more effective answers. Dave -----Original Message----- From: jeremy brand [mailto:jeremy@nirvani.net] Sent: Friday, December 15, 2000 4:15 PM To: John Damask Cc: php-general@lists.php.net Subject: Re: [PHP] File locking & cron jobs Keep in mind that php's flock() is only valid for php scripts, it does (AFAIK) no OS or filesystem type locking. What your are worried about, is a valid concern. You should try and find another way to do it if you want to be 100% sure about your solution. Jeremy Brand :: Sr. Software Engineer :: 408-245-9058 :: jeremy@nirvani.net http://www.JeremyBrand.com/Jeremy/Brand/Jeremy_Brand.html for more Get your own Free, Private email at http://www.smackdown.com/ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - At least for the people who send me mail about a new language that they're designing, the general advice is: do it to learn about how to write a compiler. --Dennis Ritchie On Fri, 15 Dec 2000, John Damask wrote: > Date: Fri, 15 Dec 2000 16:09:29 -0500 > From: John Damask <jbdamask@dotclick.com> > To: php-general@lists.php.net > Subject: [PHP] File locking & cron jobs > > Hi > I've got some files on an extranet that are modifiable by certain users. > A shell script runs as a cron job every 10 mins to copy these files to a > different web server for general viewing. > Since the cron job just copies files, do I have to worry about file locking > in PHP? > The scenario I'm concerned about is, if php fopen() runs, then the cron job > picks that file for copy before fputs() or fclose() are called, will there > be problems? > I'm hesitant to lock files from PHP - not using flock() but a system that my > shell script will adhere to as well - because I fear > user-Internet-connection-anything-can-go-wrong causing lock files to not be > cleaned up properly. > thanks > John > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > For additional commands, e-mail: php-general-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net For additional commands, e-mail: php-general-help@lists.php.net To contact the list administrators, e-mail: php-list-admin@lists.php.net

« previous php.general (#30593) next »