Laravel 不是 运行 个职位

Laravel not running jobs

我正在使用 laravel 5.2,我的作业设置为:

<?php

namespace App\Console;

use Illuminate\Console\Scheduling\Schedule;
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;

class Kernel extends ConsoleKernel
{
    /**
     * The Artisan commands provided by your application.
     *
     * @var array
     */
    protected $commands = [
        \App\Console\Commands\FetchTweets::class,
        \App\Console\Commands\FetchTweetMentions::class,
        \App\Console\Commands\FetchTweetListsAddedToo::class,
        \App\Console\Commands\LogRotater::class,
        \App\Console\Commands\FetchReadMes::class,
        \App\Console\Commands\FetchEveMarketPrices::class,
        \App\Console\Commands\FetchEveRegions::class,
        \App\Console\Commands\FetchEveMarketGroupInformation::class,
        \App\Console\Commands\FetchEveMarketTypes::class,
        \App\Console\Commands\FetchEveOnlineRegionTypeHistoryInformation::class,
        \App\Console\Commands\CleanEveTables::class,
        \App\Console\Commands\PublishTweets::class,
        \App\Console\Commands\FetchTwitterBlocks::class,
        \App\Console\Commands\FetchTwitterFollowers::class
    ];

    /**
     * Define the application's command schedule.
     *
     * @param  \Illuminate\Console\Scheduling\Schedule  $schedule
     * @return void
     */
    protected function schedule(Schedule $schedule)
    {
        // ...

        $schedule->command('log_rotater')
            ->everyThirtyMinutes()
            ->withoutOverlapping()
            ->appendOutputTo('storage/logs/log_rotation.log');
    }
}

我已经注释掉了其他工作,因为我觉得如果我修复了一个,它就会修复所有的问题,或者我会有办法修复所有的问题。基本上这份工作从来没有 运行s.

永远。

我怎么知道的?当日志文件永远不会超过 1 兆时,它应该轮换的日志文件的大小会增长到远远超过几个演出。我以前是每天设置的,现在改为每半小时一次

它仍然没有 运行。

我可以通过 php artisan log_rotator 手动 运行 它并且没有错误,它 运行s,它旋转日志寿命很长。

但它似乎不想运行按计划进行。

想法?

您是否为 运行 调度程序创建了实际的 cronjob?

# m h  dom mon dow   command
* * * * * php ~/personal_site/artisan schedule:run >> /dev/null 2>&1

命令是否有效?

这是输出之一的示例:

xxx@ubuntu:~$ php ~/personal_site/artisan schedule:run
Running scheduled command: (touch /home/xxx/personal_site/storage/framework/schedule-1b9fbd28988b6ce27513da6dcf3d00eec059484c; '/usr/bin/php7.0' 'artisan' fetch_tweets; rm /home/xxx/personal_site/storage/framework/schedule-1b9fbd28988b6ce27513da6dcf3d00eec059484c) >> 'storage/logs/tweets.log' 2>&1 &

所以....是的是的。

帮助

更新二

以下内容几乎可以告诉您您需要知道的一切。

xxx@ubuntu:~$ php /home/xxx/personal_site/artisan schedule:run >> /home/xxx/personal_site/storage/cron.log 2>&1
xxx@ubuntu:~$ cd personal_site/storage/
xxx@ubuntu:~/personal_site/storage$ cat cron.log 
Running scheduled command: (touch /home/xxx/personal_site/storage/framework/schedule-1b9fbd28988b6ce27513da6dcf3d00eec059484c; '/usr/bin/php7.0' 'artisan' fetch_tweets; rm /home/xxx/personal_site/storage/framework/schedule-1b9fbd28988b6ce27513da6dcf3d00eec059484c) >> 'storage/logs/tweets.log' 2>&1 &
Running scheduled command: (touch /home/xxx/personal_site/storage/framework/schedule-8f666afb45a162c3e7fcdd31c3b7334b7321f169; '/usr/bin/php7.0' 'artisan' fetch_twitter_blocks; rm /home/xxx/personal_site/storage/framework/schedule-8f666afb45a162c3e7fcdd31c3b7334b7321f169) >> 'storage/logs/tweet_block.log' 2>&1 &
Running scheduled command: (touch /home/xxx/personal_site/storage/framework/schedule-00cca655481aaf25de2c659589a2eb94feaf5775; '/usr/bin/php7.0' 'artisan' fetch_twitter_followers; rm /home/xxx/personal_site/storage/framework/schedule-00cca655481aaf25de2c659589a2eb94feaf5775) >> 'storage/logs/twitter_followers.log' 2>&1 &
Running scheduled command: (touch /home/xxx/personal_site/storage/framework/schedule-ee75cb261c4f273c31e1c7ce526ee8ad0b810907; '/usr/bin/php7.0' 'artisan' fetch_tweet_mentions; rm /home/xxx/personal_site/storage/framework/schedule-ee75cb261c4f273c31e1c7ce526ee8ad0b810907) >> 'storage/logs/tweet_mentions.log' 2>&1 &
Running scheduled command: (touch /home/xxx/personal_site/storage/framework/schedule-3b5a4c06df2d042fff061daba42e20e7e4ff43fc; '/usr/bin/php7.0' 'artisan' fetch_tweet_lists_added_too; rm /home/xxx/personal_site/storage/framework/schedule-3b5a4c06df2d042fff061daba42e20e7e4ff43fc) >> 'storage/logs/tweet_list.log' 2>&1 &
Running scheduled command: (touch /home/xxx/personal_site/storage/framework/schedule-1b9fbd28988b6ce27513da6dcf3d00eec059484c; '/usr/bin/php7.0' 'artisan' fetch_tweets; rm /home/xxx/personal_site/storage/framework/schedule-1b9fbd28988b6ce27513da6dcf3d00eec059484c) >> 'storage/logs/tweets.log' 2>&1 &
Running scheduled command: (touch /home/xxx/personal_site/storage/framework/schedule-8f666afb45a162c3e7fcdd31c3b7334b7321f169; '/usr/bin/php7.0' 'artisan' fetch_twitter_blocks; rm /home/xxx/personal_site/storage/framework/schedule-8f666afb45a162c3e7fcdd31c3b7334b7321f169) >> 'storage/logs/tweet_block.log' 2>&1 &
Running scheduled command: (touch /home/xxx/personal_site/storage/framework/schedule-00cca655481aaf25de2c659589a2eb94feaf5775; '/usr/bin/php7.0' 'artisan' fetch_twitter_followers; rm /home/xxx/personal_site/storage/framework/schedule-00cca655481aaf25de2c659589a2eb94feaf5775) >> 'storage/logs/twitter_followers.log' 2>&1 &
Running scheduled command: (touch /home/xxx/personal_site/storage/framework/schedule-ee75cb261c4f273c31e1c7ce526ee8ad0b810907; '/usr/bin/php7.0' 'artisan' fetch_tweet_mentions; rm /home/xxx/personal_site/storage/framework/schedule-ee75cb261c4f273c31e1c7ce526ee8ad0b810907) >> 'storage/logs/tweet_mentions.log' 2>&1 &
Running scheduled command: (touch /home/xxx/personal_site/storage/framework/schedule-3b5a4c06df2d042fff061daba42e20e7e4ff43fc; '/usr/bin/php7.0' 'artisan' fetch_tweet_lists_added_too; rm /home/xxx/personal_site/storage/framework/schedule-3b5a4c06df2d042fff061daba42e20e7e4ff43fc) >> 'storage/logs/tweet_list.log' 2>&1 &
Running scheduled command: (touch /home/xxx/personal_site/storage/framework/schedule-1357d5ceb1399278a39d91725089a0df39036ecc; '/usr/bin/php7.0' 'artisan' publish_tweets; rm /home/xxx/personal_site/storage/framework/schedule-1357d5ceb1399278a39d91725089a0df39036ecc) >> 'storage/logs/sent_tweets.log' 2>&1 &
Running scheduled command: (touch /home/xxx/personal_site/storage/framework/schedule-1b9fbd28988b6ce27513da6dcf3d00eec059484c; '/usr/bin/php7.0' 'artisan' fetch_tweets; rm /home/xxx/personal_site/storage/framework/schedule-1b9fbd28988b6ce27513da6dcf3d00eec059484c) >> 'storage/logs/tweets.log' 2>&1 &
Running scheduled command: (touch /home/xxx/personal_site/storage/framework/schedule-8f666afb45a162c3e7fcdd31c3b7334b7321f169; '/usr/bin/php7.0' 'artisan' fetch_twitter_blocks; rm /home/xxx/personal_site/storage/framework/schedule-8f666afb45a162c3e7fcdd31c3b7334b7321f169) >> 'storage/logs/tweet_block.log' 2>&1 &
Running scheduled command: (touch /home/xxx/personal_site/storage/framework/schedule-00cca655481aaf25de2c659589a2eb94feaf5775; '/usr/bin/php7.0' 'artisan' fetch_twitter_followers; rm /home/xxx/personal_site/storage/framework/schedule-00cca655481aaf25de2c659589a2eb94feaf5775) >> 'storage/logs/twitter_followers.log' 2>&1 &
Running scheduled command: (touch /home/xxx/personal_site/storage/framework/schedule-ee75cb261c4f273c31e1c7ce526ee8ad0b810907; '/usr/bin/php7.0' 'artisan' fetch_tweet_mentions; rm /home/xxx/personal_site/storage/framework/schedule-ee75cb261c4f273c31e1c7ce526ee8ad0b810907) >> 'storage/logs/tweet_mentions.log' 2>&1 &
Running scheduled command: (touch /home/xxx/personal_site/storage/framework/schedule-3b5a4c06df2d042fff061daba42e20e7e4ff43fc; '/usr/bin/php7.0' 'artisan' fetch_tweet_lists_added_too; rm /home/xxx/personal_site/storage/framework/schedule-3b5a4c06df2d042fff061daba42e20e7e4ff43fc) >> 'storage/logs/tweet_list.log' 2>&1 &
Running scheduled command: (touch /home/xxx/personal_site/storage/framework/schedule-1357d5ceb1399278a39d91725089a0df39036ecc; '/usr/bin/php7.0' 'artisan' publish_tweets; rm /home/xxx/personal_site/storage/framework/schedule-1357d5ceb1399278a39d91725089a0df39036ecc) >> 'storage/logs/sent_tweets.log' 2>&1 &

我认为@tkausl 在正确的轨道上:你命令开头的“~”可能没有指向你期望的根文件夹...

我会先删除 stdout/stderr 重定向,也许通过在你的 cron 文件顶部添加这个来给你自己发邮件:

MAILTO=me@company.com
MAILFROM=server@company.com

这应该能让您看到 cron 作业输出的任何错误消息...

正如我所说,我的猜测是您的 cron 作业是以与您不同的用户身份运行的(也许是 root 用户?)并且“~/personal_site/artisan”在此上下文中不存在...

或者,您也可以直接尝试使用绝对路径,看看是否是问题所在...

希望对您有所帮助!

查看您的调度方法,我认为这是不正确的:

$schedule->command('log_rotater')
   .....

你在这里提到了log_rotater;但是你 $signature\App\Console\Commands\LogRotater::class 中看起来怎么样 大概是这样的 log:rotate

command()的参数应该是artisan命令;所以在 \App\Console\Commands\LogRotater::class

中的 $signature 中定义

你提到你是调度程序运行;但它只运行 'FetchTweets' 任务;没有别的。