From f51470052afc632267fc9325599e75093a634d32 Mon Sep 17 00:00:00 2001 From: zhaohui Date: Mon, 5 Jan 2026 09:25:33 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4=E9=81=BF=E5=85=8D=E9=87=8D?= =?UTF-8?q?=E5=A4=8D=E8=BF=90=E8=A1=8C=E7=9A=84=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- crontab/crosscheck_auto_shell_v2.php | 40 +++++++++++++++++++++++++----------- 1 file changed, 28 insertions(+), 12 deletions(-) diff --git a/crontab/crosscheck_auto_shell_v2.php b/crontab/crosscheck_auto_shell_v2.php index 9c124ac..d11b6e9 100644 --- a/crontab/crosscheck_auto_shell_v2.php +++ b/crontab/crosscheck_auto_shell_v2.php @@ -1,14 +1,12 @@ getMessage(); file_put_contents($log_file, $str_log . PHP_EOL, FILE_APPEND); - // 删除锁文件 - unlink($lock_file); -} \ No newline at end of file +} + + + /** + * 进程上限限制 + * + * @return boolean + */ + function cProcessNum() { + // 当前程序文件名包含路径 + $path_deal = __FILE__; + $processnum = 1; + $cmd = "ps -ef | grep '{$path_deal}' | grep -v grep | grep -v '\/bin\/sh' | grep -v 'sh -c' | wc -l"; + $rcmd = @popen($cmd, 'r'); + $num = @fread($rcmd, 512); + $num += 0; + echo "[$path_deal]进程数超过{$processnum}个,当前进程数{$num}个\n"; + @pclose($rcmd); + if($num >$processnum) { + return false; + } + return true; + } \ No newline at end of file