mirror of
https://gitee.com/ulthon/ulthon_admin.git
synced 2026-07-01 15:32:48 +08:00
T7: TimerBase shouldExecuteTask() - main/auto/all/manual/disabled modes
with two-phase DB row lock for auto mode
T8: TimerControllerBase - host_id param, logStart/logEnd methods
TimerServiceBase - inject host_id into site URLs
T9: TimerLogClean command - php think admin:timer:log:clean --days=30
35 lines
930 B
PHP
35 lines
930 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace base\common\command\admin\timer;
|
|
|
|
use app\common\console\Command;
|
|
use think\console\Input;
|
|
use think\console\input\Option;
|
|
use think\console\Output;
|
|
use think\facade\Db;
|
|
|
|
class TimerLogCleanBase extends Command
|
|
{
|
|
protected function configure()
|
|
{
|
|
parent::configure();
|
|
$this->setName('admin:timer:log:clean')
|
|
->addOption('days', 'd', Option::VALUE_OPTIONAL, '清理多少天前的日志', 30)
|
|
->setDescription('清理定时器执行日志');
|
|
}
|
|
|
|
protected function execute(Input $input, Output $output)
|
|
{
|
|
$days = (int) $input->getOption('days');
|
|
$threshold = time() - ($days * 86400);
|
|
|
|
$count = Db::name('system_timer_log')
|
|
->where('create_time', '<', $threshold)
|
|
->delete();
|
|
|
|
$output->writeln("已清理 {$count} 条超过 {$days} 天的定时器执行日志。");
|
|
}
|
|
}
|