yylAdmin yylAdmin
首页
  • 介绍
  • 基础
  • 安装
  • 目录
  • 配置
  • 鸣谢
  • 支持
  • 更新日志
  • 开发
  • 前端
  • 后端
  • 调试
  • 开发工具推荐
  • 宝塔面板部署
  • 前后端部署到同一域名
  • 跨域问题
  • 接口文档问题
  • NodeJS版本问题
  • 新版文档
  • v4
  • v3
演示
Gitee (opens new window)
GitHub (opens new window)
首页
  • 介绍
  • 基础
  • 安装
  • 目录
  • 配置
  • 鸣谢
  • 支持
  • 更新日志
  • 开发
  • 前端
  • 后端
  • 调试
  • 开发工具推荐
  • 宝塔面板部署
  • 前后端部署到同一域名
  • 跨域问题
  • 接口文档问题
  • NodeJS版本问题
  • 新版文档
  • v4
  • v3
演示
Gitee (opens new window)
GitHub (opens new window)
  • 开发

    • 新增功能
    • 添加后台接口
    • 添加后台菜单权限
    • 添加后台页面
    • 刷新后台菜单权限
    • 添加前台接口
    • 添加接口文档调试
    • 接口生成器
  • 前端

    • Token
    • 多级目录
  • 后端

    • 缓存
    • 定时任务
      • 定时任务
        • 添加定时操作
        • 开启定时任务
        • 开发模式开启
        • 守护进程方式开启
        • 守护进程并设置间隔时间开启
        • 查看定时任务参数
    • 队列支持
  • 调试

    • 接口文档
目录

定时任务

# 定时任务

# 添加定时操作

在 app\command\Timer 的 start 方法中添加需要定时执行的操作
app\command\Timer

try {
    // 会员日志清除
    LogService::clearLog();
} catch (\Exception $e) {
    echo 'timer member-log-clear ' . $e->getMessage() . PHP_EOL;
}

# 开启定时任务

# 开发模式开启

php think timer

debug 模式,开发调试使用

# 守护进程方式开启

php think timer --mode d

daemon 模式,正式部署使用

# 守护进程并设置间隔时间开启

php think timer --mode d --interval 1

--interval 1,间隔时间为1秒,即每秒执行一次
设置:开启时传入参数或在 app\command\Timer 修改

# 查看定时任务参数

php think timer --help
Usage:
  timer [options] [--] [<action>]

Arguments:
  action                     start|stop|restart|reload|status|connections [default: "start"]

Options:
  -m, --mode[=MODE]          daemon(守护进程)方式启动
  -i, --interval[=INTERVAL]  多长时间执行一次
  -h, --help                 Display this help message
  -V, --version              Display this console version
  -q, --quiet                Do not output any message
      --ansi                 Force ANSI output
      --no-ansi              Disable ANSI output
  -n, --no-interaction       Do not ask any interactive question
  -v|vv|vvv, --verbose       Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug

注意

确保执行命令的用户有足够权限或添加 sudo

上次更新: 2024/04/12, 20:29:30
缓存
队列支持

← 缓存 队列支持→

Theme by Vdoing | Copyright © 2018-2024 yylAdmin | Apache-2.0
  • 跟随系统
  • 浅色模式
  • 深色模式
  • 阅读模式