News Feed
Sections




News Archive
Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Andrew Johnstone's Blog:
Lock Files in PHP & Bash
January 05, 2010 @ 12:40:39

Andrew Johnstone, inspired by a previous post on file locking to avoid cron job overlaps, as posted his own method and give a few more examples of how it can be done.

In order for a lock to work correctly it must handle, Atomicity / Race Conditions, and Signaling. I use the following bash script to create locks for crontabs and ensure single execution of scripts.

His bash script looks at the processes currently running and checks to be sure there's not already one there. If not, it takes the script given and executes an instance. If the process has finished running but the lock file is still there, it removes it and moves on to the execute. He includes a few examples of how to use it and the code for a PHP class that makes it easy to check if something's running, locked or what the current signal/status of the process is.

0 comments voice your opinion now!
lock file bash script tutorial


blog comments powered by Disqus

Similar Posts

Fabien Potencier's Blog: Parsing XML documents with CSS selectors

DevShed: Using the Memento Pattern with a File Reading Class

Johannes Schluter's Blog: MySQL Storage Engine based on PHP

Gonzalo Ayuso's Blog: Building a simple SQL wrapper with PHP. Part 2.

MaltBlue.com: Zend Form Mastery with Zend_Config - Part 3, Standard Form & Element Options


Community Events





Don't see your event here?
Let us know!


refactor list interview laravel api introduction threedevsandamaybe unittest testing developer language release opinion podcast community code install framework series symfony2

All content copyright, 2014 PHPDeveloper.org :: info@phpdeveloper.org - Powered by the Solar PHP Framework