From f602b81cd1c41b9ad2d8a9153e03acec7810fa19 Mon Sep 17 00:00:00 2001 From: zhaohui Date: Tue, 6 Jan 2026 16:10:55 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4=E5=A4=B1=E8=B4=A5=E6=AC=A1?= =?UTF-8?q?=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- crontab/crosscheck_auto_shell.php | 39 ++++++++++++++++++++++++++++++--------- 1 file changed, 30 insertions(+), 9 deletions(-) diff --git a/crontab/crosscheck_auto_shell.php b/crontab/crosscheck_auto_shell.php index c1df924..05ffa49 100644 --- a/crontab/crosscheck_auto_shell.php +++ b/crontab/crosscheck_auto_shell.php @@ -1,14 +1,12 @@ getCrossCheckAccount(); - + print_r($list); + echo "\n"; + exit; //测试数据 $list[] = [ 'user' => 'mayi001', @@ -105,4 +105,25 @@ try{ 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