composer
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
$output->writeln('ok');
|
||||
return self::SUCCESS;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user