Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
603 views
in Technique[技术] by (71.8m points)

php - Laravel "No scheduled commands are ready to run."

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

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

1 Reply

0 votes
by (71.8m points)

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...