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.