PHP通过lock控制进程只执行一次
$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}\n");
}
if (!flock($lock_file_handle, LOCK_EX + LOCK_NB)){
die(date("Y-m-d H:i:s"). " Process already exists.\n");
}