Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I've set up the following Laravel commands:

protected function schedule(Schedule $schedule) {
        $schedule->command('command:daily-reset')->daily();
        $schedule->command('command:monthly-reset')->monthly();
}

Then, on my server, I've set up a cron job to run once per day (at 00:00).

0 0 * * * php /home/privates/public_html/staging/current/artisan schedule:run

My cron job is running successfully each night, but the logs simply say: "No scheduled commands are ready to run."

What am I doing wrong? I would expect my daily command to run each night.

Thanks!

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
592 views
Welcome To Ask or Share your Answers For Others

1 Answer

When you run

php artisan schedule:run

in the server, where your project is stored, you could see all of your commands running with output, looking like this:

"Running scheduled command: '/usr/local/bin/php' 'artisan' cache:update > '/dev/null' 2>&1 &"

but only if the current time is the exact one, for which the command is scheduled. Otherwise you are going to see this output:

"No scheduled commands are ready to run."

For example, if you schedule the command for every five minutes and run the command in 09:07 o'clock you will see that there are no scheduled commands, but if you run it in 09:10 you will see your command running.

In this way you can just schedule your command to run every 5 min just for debugging purposes:

$schedule->command('command:daily-reset')->everyFiveMinutes();

then observe if there is any error while running and eventually fix it. By me the problem was that I haven't installed GuzzleHttp (shame), so the fix was just running this in the terminal:

composer require guzzlehttp/guzzle

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...