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