I'd use a Lockfile.
As an idea: Open the file for writing, lock it (or stop here, if it is already locked), write your PID in it (I like to know the pid's of running processes) and unlock (and close of course) it when you're done.
That's just an idea. If someone knows con's about this technique, please tell :)