How to prevent PHP script running more than once?

前端 未结 6 911
臣服心动
臣服心动 2020-12-05 16:23

Currently, I tried to prevent an onlytask.php script from running more than once:

$fp = fopen(\"/tmp/\".\"onlyme.lock\", \"a+\");
if (flock($fp,         


        
6条回答
  •  孤城傲影
    2020-12-05 16:43

    You can add an extra check by writing the pid and then check it within file_exist-statement. To secure it even more you can fetch all running applications by "ps fax" end check if this file is in the list.

提交回复
热议问题