From f57512a312d9af1ecca7176f28fa7a60922c7747 Mon Sep 17 00:00:00 2001 From: ASUS <515617283@qq.com> Date: Fri, 15 Aug 2025 14:34:48 +0800 Subject: [PATCH] composer --- app/command/Logzip.php | 45 ++++++++++++++++++++---------------------- 1 file changed, 21 insertions(+), 24 deletions(-) diff --git a/app/command/Logzip.php b/app/command/Logzip.php index 18992ac..1540ffc 100644 --- a/app/command/Logzip.php +++ b/app/command/Logzip.php @@ -7,7 +7,7 @@ use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Output\OutputInterface; - +use ZipArchive; class Logzip extends Command { @@ -29,24 +29,23 @@ class Logzip extends Command */ protected function execute(InputInterface $input, OutputInterface $output): int { - $dir_arr = [ - 'runtime/admin/log/', - 'runtime/api/log/', - 'runtime/czg/log/', - 'runtime/log/', - ]; - $yestermonth = date("Ym"); +// $dir_arr = [ +// 'runtime/logs/', +// ]; + $dir = 'runtime/logs/'; // 如果今天是1号 - if(date('d') == 01 || date('d') == 1) { - $yestermonth = date("Ym", strtotime('-1 month')); - } - foreach ($dir_arr as $dir_a) { - $file_arr = getYesterdayFiles($dir_a . $yestermonth . '/'); - if(!empty($file_arr['files'])) { - foreach ($file_arr['files'] as $k => $file_p) { - $file = $dir_a . $yestermonth . '/' . $file_p; - $zip_filename = str_replace('.log', '.zip', $file_p); - $file_zip = $dir_a . $yestermonth . '/' . $zip_filename; + $yestermonth = date("Y-m-d", strtotime('-1 day')); + $file_p = 'webman-' . $yestermonth . '.log'; + $dir .= $file_p; +// foreach ($dir_arr as $dir_a) { +// $file_arr = getYesterdayFiles($dir_a . $yestermonth . '/'); +// if(!empty($file_arr['files'])) { +// foreach ($file_arr['files'] as $k => $file_p) { +// $file = $dir_a . $yestermonth . '/' . $file_p; + $file = $dir; +// $zip_filename = str_replace('.log', '.zip', $file); + $file_zip = str_replace('.log', '.zip', $file); +// $file_zip = $dir_a . $yestermonth . '/' . $zip_filename; $is_close = false; if(!file_exists($file_zip)) { $zip = new ZipArchive(); @@ -59,16 +58,14 @@ class Logzip extends Command } if ($is_close) { if($zip->close()) { - if($is_close) { - unlink($file); - } + unlink($file); } } } } - } - } - } +// } +// } +// } $output->writeln('ok'); return self::SUCCESS; }