首页 > 解决方案 > Laravel 调度:钩子后没有被调用

问题描述

我的 laravel (5.8) 应用程序位于文件夹中的共享主机上app。绑定到域的文件夹public_html位于app. 我有一个这样的计划任务:

$schedule->command('feed:gen sitemap')
             ->withoutOverlapping()
             ->runInBackground()
             ->dailyAt('03:00')
             ->after(function() use($schedule) {
                $schedule->exec('mv ~/app/public/Sitemap.xml ~/public_html/Sitemap.xml');
             });

创建 sitemap.xml 并将其移动到网站根文件夹。该command部分工作正常,sitemap.xml 在~/app/文件夹中创建,但after()不会调用钩子。我很确定mv命令的路径很好。另一方面,文档中不清楚如何链接多个调用,包括钩子,以及哪些函数调用可以相互链接。也许我需要将其他东西链接到$schedule->exec()...

PS:feed:gen sitemap命令注册在routes/console.phplike

Artisan::command('feed:gen {type}', function (FeedGenerator $gen, $type) {
    // some code
})->describe('Generates feeds for site');

标签: phplaravel-5cron

解决方案


推荐阅读