Files
ulthon_admin/extend/base/common/command/admin/timer/TimerLogCleanBase.php
augushong 25fab093fa feat(timer): 新增 run_type 调度、host_id 投递和日志清理
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
2026-05-26 18:33:42 +08:00

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} 天的定时器执行日志。");
}
}