By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,350 Members | 1,309 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,350 IT Pros & Developers. It's quick & easy.

When to flock

P: n/a
I've got a script which writes my blog's RSS feed (rather than dynamically
generating it each time it is requested), and I'm not sure whether I should
lock the file while I'm writing it. Truth is, the only way this script
runs is through cron anyway, and I recently read that "Other processes can
modify or delete a PHP-locked file if permissions allow." which seems to be
a waste of time, anyway.

Can someone shed light on this?
Thanks

--
Karl Groves
http://karlcore.com
http://chevelle.karlcore.com
Mar 2 '07 #1
Share this Question
Share on Google+
2 Replies


P: n/a
>I've got a script which writes my blog's RSS feed (rather than dynamically
>generating it each time it is requested), and I'm not sure whether I should
lock the file while I'm writing it. Truth is, the only way this script
runs is through cron anyway, and I recently read that "Other processes can
modify or delete a PHP-locked file if permissions allow." which seems to be
a waste of time, anyway.

Can someone shed light on this?
Always be prepared to deal with problems with slow cron jobs. If
you run it every 6 hours and it sends an email, be prepared to deal
with what happens if sending an email takes 13 hours (perhaps a
NFS-mounted volume went offline). The solution is NOT to stack up
more processes indefinitely.

Mar 2 '07 #2

P: n/a
Karl Groves wrote:
I've got a script which writes my blog's RSS feed (rather than dynamically
generating it each time it is requested), and I'm not sure whether I should
lock the file while I'm writing it.
Why would you want to? Assuming this script only runs every hour or two,
it's unlikely that two attempts will be made to write to the file
simultaneously. Of course if someone *reads* the file while it's being
written, they'll get a partial feed, but flock() doesn't change that.

--
Toby A Inkster BSc (Hons) ARCS
Contact Me ~ http://tobyinkster.co.uk/contact
Geek of ~ HTML/SQL/Perl/PHP/Python*/Apache/Linux

* = I'm getting there!
Mar 5 '07 #3

This discussion thread is closed

Replies have been disabled for this discussion.