加入 flock鎖機制php
* * * * * flock -xn /tmp/mytest.lock -c 'php test.php >> /test.log' shell
- -s, --shared: 得到一個共享鎖
- -x, --exclusive: 得到一個獨佔鎖
- -u, --unlock: 移除一個鎖,一般是不須要的,腳本執行完會自動丟棄鎖
- -n, --nonblock: 若是沒有當即得到鎖,直接失敗而不是等待
- -w, --timeout: 若是沒有當即得到鎖,等待指定時間
- -o, --close: 在運行命令前關閉文件的描述符號。用於若是命令產生子進程時會不受鎖的管控
- -c, --command: 在shell中運行一個單獨的命令
- -h, --help 顯示幫助
- -V, --version: 顯示版本