<? $fp = fopen("foo.txt", "w"); if (flock($fp, LOCK_EX | LOCK_NB)) { echo "Got lock!\n"; sleep(10); flock($fp, LOCK_UN); } else { print "Could not get lock!\n"; } ?>