$lock_file = dirname(__FILE__) . "/process.lock";
$lock_file_handle = fopen($lock_file, 'w');
if ($lock_file_handle === false){
die("can not create lock file {$lock_file}
");
}
if (!flock($lock_file_handle, LOCK_EX + LOCK_NB)){
die(date("Y-m-d H:i:s"). " Process already exists.
");
}