| 12345678910111213141516171819202122232425262728293031323334353637383940 |
- <?php
- namespace app\command;
- use app\common\model\shared\SharedProsperityPartnerConsumeUpdateLog;
- use app\common\repositories\shared\SharedProsperityRecommendConfigRepository;
- use think\console\Command;
- use think\console\Input;
- use think\console\Output;
- use think\facade\Db;
- class DeleteApiLog extends Command
- {
- // 上级
- const DAY = 7;
- protected function configure()
- {
- // 指令配置
- $this->setName('deleteApiLog')
- ->setDescription('定时删除api日志');
- }
- protected function execute(Input $input, Output $output)
- {
- $output->writeln('定时任务执行中...');
- $this->delete();
- $output->writeln('定时任务执行完成');
- }
- private function delete()
- {
- $time = time() - self::DAY * 24 * 60 * 60;
- $time = date('Y-m-d', $time);
- Db::name('api_request_log')->where('create_time', '<', $time)->limit(1000)->delete();
- }
- }
|