How can I ensure I have only one instance of a PHP script running via Apache?

前端 未结 3 1627
暗喜
暗喜 2020-12-14 04:40

I have an index.php script that I use as a post-commit URL on a Google Code site. This script clones a directory and builds a project that may take some work.

3条回答
  •  佛祖请我去吃肉
    2020-12-14 05:16

    You can use flock with LOCK_EX to gain an exclusive lock on a file.

    E.g.:

    
    

    For PHP versions after 5.3.2 you need to manually release the lock using flock($fp, LOCK_UN);

提交回复
热议问题