Skip to content

[BUG] 定时任务执行 顺序相关 #7677

@epicsnail

Description

@epicsnail

Execute the command and paste the result below.

Command: uname -a && php -v && composer info | grep hyperf && php --ri swoole

Linux vinter 5.15.146.1-microsoft-standard-WSL2 #1 SMP Thu Jan 11 04:09:03 UTC 2024 x86_64 x86_64 x86_64 GNU/Linux
PHP 8.1.33 (cli) (built: Jul  3 2025 16:15:48) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.1.33, Copyright (c) Zend Technologies
    with Zend OPcache v8.1.33, Copyright (c), by Zend Technologies
hyperf/amqp                        3.1.63   A amqplib for hyperf.
hyperf/cache                       3.1.63   A cache component for hyperf.
hyperf/code-parser                 3.1.63   A code parser component for Hyperf.
hyperf/codec                       3.1.63   A codec component for Hyperf.
hyperf/collection                  3.1.64   Hyperf Collection package which come from illuminate/collections
hyperf/command                     3.1.64   Command for hyperf
hyperf/conditionable               3.1.63   Hyperf Macroable package which come from illuminate/conditionable
hyperf/config                      3.1.63   An independent component that provides configuration container.
hyperf/constants                   3.1.63   A constants component for hyperf.
hyperf/context                     3.1.63   A coroutine/application context library.
hyperf/contract                    3.1.63   The contracts of Hyperf.
hyperf/coordinator                 3.1.63   Hyperf Coordinator
hyperf/coroutine                   3.1.65   Hyperf Coroutine
hyperf/crontab                     3.1.63   A crontab component for Hyperf.
hyperf/database                    3.1.65   A flexible database library.
hyperf/db-connection               3.1.63   A hyperf db connection handler for hyperf/database.
hyperf/devtool                     3.1.63   A Devtool for Hyperf.
hyperf/di                          3.1.65   A DI for Hyperf.
hyperf/dispatcher                  3.1.63   A HTTP Server for Hyperf.
hyperf/elasticsearch               3.1.63   Elasticsearch client for hyperf
hyperf/engine                      2.15.0   Coroutine engine provided by swoole.
hyperf/engine-contract             1.14.0   Contract for Coroutine Engine
hyperf/event                       3.1.63   an event manager that implements PSR-14.
hyperf/exception-handler           3.1.63   Exception handler for hyperf
hyperf/framework                   3.1.63   A coroutine framework that focuses on hyperspeed and flexible, specifically use for build microservices and middlewares.
hyperf/guzzle                      3.1.65   Swoole coroutine handler for guzzle
hyperf/http-message                3.1.65   microservice framework base on swoole
hyperf/http-server                 3.1.65   A HTTP Server for Hyperf.
hyperf/json-rpc                    3.1.63   A JSON RPC component for Hyperf RPC Server or Client.
hyperf/load-balancer               3.1.63   A load balancer library for Hyperf.
hyperf/logger                      3.1.63   A logger component for hyperf.
hyperf/macroable                   3.1.63   Hyperf Macroable package which come from illuminate/macroable
hyperf/memory                      3.1.63   An independent component that use to operate and manage memory.
hyperf/model-cache                 3.1.63   A model cache component for hyperf.
hyperf/model-listener              3.1.63   A model listener for Hyperf.
hyperf/pipeline                    3.1.63   Hyperf Macroable package which come from illuminate/pipeline
hyperf/pool                        3.1.63   An independent universal connection pool component.
hyperf/process                     3.1.63   A process component for hyperf.
hyperf/redis                       3.1.63   A redis component for hyperf.
hyperf/rpc                         3.1.63   A rpc basic library for Hyperf.
hyperf/rpc-client                  3.1.63   An abstract rpc server component for Hyperf.
hyperf/rpc-server                  3.1.63   An abstract rpc server component for Hyperf.
hyperf/serializer                  3.1.63   A serializer component for Hyperf.
hyperf/server                      3.1.63   A base server library for Hyperf.
hyperf/stdlib                      3.1.63   A stdlib component for Hyperf.
hyperf/stringable                  3.1.65   Hyperf Stringable package which come from illuminate/support
hyperf/support                     3.1.65   A support component for Hyperf.
hyperf/tappable                    3.1.63   Hyperf Macroable package which come from illuminate/tappable
hyperf/testing                     3.1.63   Testing for hyperf
hyperf/tracer                      3.1.63   A open tracing system implemented for Hyperf or other coroutine framework

swoole

Swoole => enabled
Author => Swoole Team <[email protected]>
Version => 5.1.1
Built => Apr 18 2025 17:51:32
coroutine => enabled with boost asm context
epoll => enabled
eventfd => enabled
signalfd => enabled
cpu_affinity => enabled
spinlock => enabled
rwlock => enabled
http2 => enabled
json => enabled
mutex_timedlock => enabled
pthread_barrier => enabled
futex => enabled
async_redis => enabled

Directive => Local Value => Master Value
swoole.enable_coroutine => On => On
swoole.enable_library => On => On
swoole.enable_fiber_mock => Off => Off
swoole.enable_preemptive_scheduler => Off => Off
swoole.display_errors => On => On
swoole.use_shortname => Off => Off
swoole.unixsock_buffer_size => 8388608 => 8388608

Description:

Image 定时任务配置如上图 如果是command类型的定时任务在前面定义那么后面的 callback类型 和 Closure 类型 就不会执行,下面是执行结果

Triggering Crontab
int(11111111)
[INFO] Crontab task [Command] executed successfully at 2025-12-19 17:36:25.
[ERROR] Crontab task [Command] failed execution at 2025-12-19 17:36:25.
[ERROR] Crontab task [Command] failed execution at 2025-12-19 17:36:25.
[ERROR] Crontab task [Command] failed execution at 2025-12-19 17:36:25.
[ERROR] Crontab task [Command] failed execution at 2025-12-19 17:36:25.
[ERROR] Crontab task [Command] failed execution at 2025-12-19 17:36:25.
[ERROR] Crontab task [Command] failed execution at 2025-12-19 17:36:25.
[ERROR] Crontab task [Command] failed execution at 2025-12-19 17:36:25.
[ERROR] Crontab task [Command] failed execution at 2025-12-19 17:36:25.
[ERROR] Crontab task [Command] failed execution at 2025-12-19 17:36:25.
[ERROR] Crontab task [Command] failed execution at 2025-12-19 17:36:25.
[ERROR] Crontab task [Command] failed execution at 2025-12-19 17:36:25.
[ERROR] Crontab task [Command] failed execution at 2025-12-19 17:36:25.
[ERROR] Crontab task [Command] failed execution at 2025-12-19 17:36:25.
[ERROR] Crontab task [Command] failed execution at 2025-12-19 17:36:25.
[ERROR] Crontab task [Command] failed execution at 2025-12-19 17:36:25.
[ERROR] Crontab task [Command] failed execution at 2025-12-19 17:36:25.
[ERROR] Crontab task [Command] failed execution at 2025-12-19 17:36:25.
[ERROR] Crontab task [Command] failed execution at 2025-12-19 17:36:25.
[ERROR] Crontab task [Command] failed execution at 2025-12-19 17:36:25.
[ERROR] Crontab task [Command] failed execution at 2025-12-19 17:36:25.
[ERROR] Crontab task [Command] failed execution at 2025-12-19 17:36:25.
[ERROR] Crontab task [Command] failed execution at 2025-12-19 17:36:25.
[ERROR] Crontab task [Command] failed execution at 2025-12-19 17:36:25.
[ERROR] Crontab task [Command] failed execution at 2025-12-19 17:36:25.
[ERROR] Crontab task [Command] failed execution at 2025-12-19 17:36:25.
[ERROR] Crontab task [Command] failed execution at 2025-12-19 17:36:25.
[ERROR] Crontab task [Command] failed execution at 2025-12-19 17:36:25.
[ERROR] Crontab task [Command] failed execution at 2025-12-19 17:36:25.
[ERROR] Crontab task [Command] failed execution at 2025-12-19 17:36:25.
[ERROR] Crontab task [Command] failed execution at 2025-12-19 17:36:25.
[ERROR] Crontab task [Command] failed execution at 2025-12-19 17:36:25.
[ERROR] Crontab task [Command] failed execution at 2025-12-19 17:36:25.
[ERROR] Crontab task [Command] failed execution at 2025-12-19 17:36:25.
[ERROR] Crontab task [Command] failed execution at 2025-12-19 17:36:25.
[ERROR] Crontab task [Command] failed execution at 2025-12-19 17:36:25.
[ERROR] Crontab task [Command] failed execution at 2025-12-19 17:36:25.
[ERROR] Crontab task [Command] failed execution at 2025-12-19 17:36:25.
[ERROR] Crontab task [Command] failed execution at 2025-12-19 17:36:25.
[ERROR] Crontab task [Command] failed execution at 2025-12-19 17:36:25.
[ERROR] Crontab task [Command] failed execution at 2025-12-19 17:36:25.
[ERROR] Crontab task [Command] failed execution at 2025-12-19 17:36:25.
[ERROR] Crontab task [Command] failed execution at 2025-12-19 17:36:25.
[ERROR] Crontab task [Command] failed execution at 2025-12-19 17:36:25.
[ERROR] Crontab task [Command] failed execution at 2025-12-19 17:36:25.
[ERROR] Crontab task [Command] failed execution at 2025-12-19 17:36:25.
[ERROR] Crontab task [Command] failed execution at 2025-12-19 17:36:25.
[ERROR] Crontab task [Command] failed execution at 2025-12-19 17:36:25.
[ERROR] Crontab task [Command] failed execution at 2025-12-19 17:36:25.
[ERROR] Crontab task [Command] failed execution at 2025-12-19 17:36:25.
[ERROR] Crontab task [Command] failed execution at 2025-12-19 17:36:25.
[ERROR] Crontab task [Command] failed execution at 2025-12-19 17:36:25.
[ERROR] Crontab task [Command] failed execution at 2025-12-19 17:36:25.
[ERROR] Crontab task [Command] failed execution at 2025-12-19 17:36:25.
[ERROR] Crontab task [Command] failed execution at 2025-12-19 17:36:25.
[ERROR] Crontab task [Command] failed execution at 2025-12-19 17:36:25.
[ERROR] Crontab task [Command] failed execution at 2025-12-19 17:36:25.
[ERROR] Crontab task [Command] failed execution at 2025-12-19 17:36:25.
[ERROR] Crontab task [Command] failed execution at 2025-12-19 17:36:25.
[ERROR] Crontab task [Command] failed execution at 2025-12-19 17:36:25.
[ERROR] Crontab task [callback] failed execution at 2025-12-19 17:36:25.
[ERROR] Crontab task [callback] failed execution at 2025-12-19 17:36:25.
[ERROR] Crontab task [callback] failed execution at 2025-12-19 17:36:25.
[ERROR] Crontab task [callback] failed execution at 2025-12-19 17:36:25.
[ERROR] Crontab task [callback] failed execution at 2025-12-19 17:36:25.
[ERROR] Crontab task [callback] failed execution at 2025-12-19 17:36:25.
[ERROR] Crontab task [callback] failed execution at 2025-12-19 17:36:25.
[ERROR] Crontab task [callback] failed execution at 2025-12-19 17:36:25.
[ERROR] Crontab task [callback] failed execution at 2025-12-19 17:36:25.
[ERROR] Crontab task [callback] failed execution at 2025-12-19 17:36:25.
[ERROR] Crontab task [callback] failed execution at 2025-12-19 17:36:25.
[ERROR] Crontab task [callback] failed execution at 2025-12-19 17:36:25.
[ERROR] Crontab task [callback] failed execution at 2025-12-19 17:36:25.
[ERROR] Crontab task [callback] failed execution at 2025-12-19 17:36:25.
[ERROR] Crontab task [callback] failed execution at 2025-12-19 17:36:25.
[ERROR] Crontab task [callback] failed execution at 2025-12-19 17:36:25.
[ERROR] Crontab task [callback] failed execution at 2025-12-19 17:36:25.
[ERROR] Crontab task [callback] failed execution at 2025-12-19 17:36:25.
[ERROR] Crontab task [callback] failed execution at 2025-12-19 17:36:25.
[ERROR] Crontab task [callback] failed execution at 2025-12-19 17:36:25.
[ERROR] Crontab task [callback] failed execution at 2025-12-19 17:36:25.
[ERROR] Crontab task [callback] failed execution at 2025-12-19 17:36:25.
[ERROR] Crontab task [callback] failed execution at 2025-12-19 17:36:25.
[ERROR] Crontab task [callback] failed execution at 2025-12-19 17:36:25.
[ERROR] Crontab task [callback] failed execution at 2025-12-19 17:36:25.
[ERROR] Crontab task [callback] failed execution at 2025-12-19 17:36:25.
[ERROR] Crontab task [callback] failed execution at 2025-12-19 17:36:25.
[ERROR] Crontab task [callback] failed execution at 2025-12-19 17:36:25.
[ERROR] Crontab task [callback] failed execution at 2025-12-19 17:36:25.
[ERROR] Crontab task [callback] failed execution at 2025-12-19 17:36:25.
[ERROR] Crontab task [callback] failed execution at 2025-12-19 17:36:25.
[ERROR] Crontab task [callback] failed execution at 2025-12-19 17:36:25.
[ERROR] Crontab task [callback] failed execution at 2025-12-19 17:36:25.
[ERROR] Crontab task [callback] failed execution at 2025-12-19 17:36:25.
[ERROR] Crontab task [callback] failed execution at 2025-12-19 17:36:25.
[ERROR] Crontab task [callback] failed execution at 2025-12-19 17:36:25.
[ERROR] Crontab task [callback] failed execution at 2025-12-19 17:36:25.
[ERROR] Crontab task [callback] failed execution at 2025-12-19 17:36:25.
[ERROR] Crontab task [callback] failed execution at 2025-12-19 17:36:25.
[ERROR] Crontab task [callback] failed execution at 2025-12-19 17:36:25.
[ERROR] Crontab task [callback] failed execution at 2025-12-19 17:36:25.
[ERROR] Crontab task [callback] failed execution at 2025-12-19 17:36:25.
[ERROR] Crontab task [callback] failed execution at 2025-12-19 17:36:25.
[ERROR] Crontab task [callback] failed execution at 2025-12-19 17:36:25.
[ERROR] Crontab task [callback] failed execution at 2025-12-19 17:36:25.
[ERROR] Crontab task [callback] failed execution at 2025-12-19 17:36:25.
[ERROR] Crontab task [callback] failed execution at 2025-12-19 17:36:25.
[ERROR] Crontab task [callback] failed execution at 2025-12-19 17:36:25.
[ERROR] Crontab task [callback] failed execution at 2025-12-19 17:36:25.
[ERROR] Crontab task [callback] failed execution at 2025-12-19 17:36:25.
[ERROR] Crontab task [callback] failed execution at 2025-12-19 17:36:25.
[ERROR] Crontab task [callback] failed execution at 2025-12-19 17:36:25.
[ERROR] Crontab task [callback] failed execution at 2025-12-19 17:36:25.
[ERROR] Crontab task [callback] failed execution at 2025-12-19 17:36:25.
[ERROR] Crontab task [callback] failed execution at 2025-12-19 17:36:25.
[ERROR] Crontab task [callback] failed execution at 2025-12-19 17:36:25.
[ERROR] Crontab task [callback] failed execution at 2025-12-19 17:36:25.
[ERROR] Crontab task [callback] failed execution at 2025-12-19 17:36:25.
[ERROR] Crontab task [callback] failed execution at 2025-12-19 17:36:25.
[ERROR] Crontab task [callback] failed execution at 2025-12-19 17:36:25.
[ERROR] Crontab task [Closure] failed execution at 2025-12-19 17:36:25.
[ERROR] Crontab task [Closure] failed execution at 2025-12-19 17:36:25.
[ERROR] Crontab task [Closure] failed execution at 2025-12-19 17:36:25.
[ERROR] Crontab task [Closure] failed execution at 2025-12-19 17:36:25.
[ERROR] Crontab task [Closure] failed execution at 2025-12-19 17:36:25.
[ERROR] Crontab task [Closure] failed execution at 2025-12-19 17:36:25.
[ERROR] Crontab task [Closure] failed execution at 2025-12-19 17:36:25.
[ERROR] Crontab task [Closure] failed execution at 2025-12-19 17:36:25.
[ERROR] Crontab task [Closure] failed execution at 2025-12-19 17:36:25.
[ERROR] Crontab task [Closure] failed execution at 2025-12-19 17:36:25.
[ERROR] Crontab task [Closure] failed execution at 2025-12-19 17:36:25.
[ERROR] Crontab task [Closure] failed execution at 2025-12-19 17:36:25.
[ERROR] Crontab task [Closure] failed execution at 2025-12-19 17:36:25.
[ERROR] Crontab task [Closure] failed execution at 2025-12-19 17:36:25.
[ERROR] Crontab task [Closure] failed execution at 2025-12-19 17:36:25.
[ERROR] Crontab task [Closure] failed execution at 2025-12-19 17:36:25.
[ERROR] Crontab task [Closure] failed execution at 2025-12-19 17:36:25.
[ERROR] Crontab task [Closure] failed execution at 2025-12-19 17:36:25.
[ERROR] Crontab task [Closure] failed execution at 2025-12-19 17:36:25.
[ERROR] Crontab task [Closure] failed execution at 2025-12-19 17:36:25.
[ERROR] Crontab task [Closure] failed execution at 2025-12-19 17:36:25.
[ERROR] Crontab task [Closure] failed execution at 2025-12-19 17:36:25.
[ERROR] Crontab task [Closure] failed execution at 2025-12-19 17:36:25.
[ERROR] Crontab task [Closure] failed execution at 2025-12-19 17:36:25.
[ERROR] Crontab task [Closure] failed execution at 2025-12-19 17:36:25.
[ERROR] Crontab task [Closure] failed execution at 2025-12-19 17:36:25.
[ERROR] Crontab task [Closure] failed execution at 2025-12-19 17:36:25.
[ERROR] Crontab task [Closure] failed execution at 2025-12-19 17:36:25.
[ERROR] Crontab task [Closure] failed execution at 2025-12-19 17:36:25.
[ERROR] Crontab task [Closure] failed execution at 2025-12-19 17:36:25.
[ERROR] Crontab task [Closure] failed execution at 2025-12-19 17:36:25.
[ERROR] Crontab task [Closure] failed execution at 2025-12-19 17:36:25.
[ERROR] Crontab task [Closure] failed execution at 2025-12-19 17:36:25.
[ERROR] Crontab task [Closure] failed execution at 2025-12-19 17:36:25.
[ERROR] Crontab task [Closure] failed execution at 2025-12-19 17:36:25.
[ERROR] Crontab task [Closure] failed execution at 2025-12-19 17:36:25.
[ERROR] Crontab task [Closure] failed execution at 2025-12-19 17:36:25.
[ERROR] Crontab task [Closure] failed execution at 2025-12-19 17:36:25.
[ERROR] Crontab task [Closure] failed execution at 2025-12-19 17:36:25.
[ERROR] Crontab task [Closure] failed execution at 2025-12-19 17:36:25.
[ERROR] Crontab task [Closure] failed execution at 2025-12-19 17:36:25.
[ERROR] Crontab task [Closure] failed execution at 2025-12-19 17:36:25.
[ERROR] Crontab task [Closure] failed execution at 2025-12-19 17:36:25.
[ERROR] Crontab task [Closure] failed execution at 2025-12-19 17:36:25.
[ERROR] Crontab task [Closure] failed execution at 2025-12-19 17:36:25.
[ERROR] Crontab task [Closure] failed execution at 2025-12-19 17:36:25.
[ERROR] Crontab task [Closure] failed execution at 2025-12-19 17:36:25.
[ERROR] Crontab task [Closure] failed execution at 2025-12-19 17:36:25.
[ERROR] Crontab task [Closure] failed execution at 2025-12-19 17:36:25.
[ERROR] Crontab task [Closure] failed execution at 2025-12-19 17:36:25.
[ERROR] Crontab task [Closure] failed execution at 2025-12-19 17:36:25.
[ERROR] Crontab task [Closure] failed execution at 2025-12-19 17:36:25.
[ERROR] Crontab task [Closure] failed execution at 2025-12-19 17:36:25.
[ERROR] Crontab task [Closure] failed execution at 2025-12-19 17:36:25.
[ERROR] Crontab task [Closure] failed execution at 2025-12-19 17:36:25.
[ERROR] Crontab task [Closure] failed execution at 2025-12-19 17:36:25.
[ERROR] Crontab task [Closure] failed execution at 2025-12-19 17:36:25.
[ERROR] Crontab task [Closure] failed execution at 2025-12-19 17:36:25.
[ERROR] Crontab task [Closure] failed execution at 2025-12-19 17:36:25.
[ERROR] Crontab task [Closure] failed execution at 2025-12-19 17:36:25.

如果将callback类型放在前面则会执行 callback 和 command 类型 closure 不执行
如果顺序是 closure 、callback 和 command 则会依次执行
通过crontab注解定义的任务也会有影响

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions