Summer Sale! All accounts are 50% off this week.

MohammadAbusaleh's avatar

Taskscheduler 'No scheduled commands are ready to run.'

Hello,

I'm trying to run a scheduler on Ubuntu 18.04, This is my Kernel.php

    protected $commands = [
        IntegrityCheck::class
    ];

    protected function schedule(Schedule $schedule)
    {
        $schedule->command('integrity:check')->everyMinute();
    }

My IntegrityCheck.php:

    protected $signature = 'integrity:check';

    public function handle(){
        Log::info('This is running');
        $this->info('Integrity Check Done');
    }

My crontab:

    * * * * * cd /home/me/Sites/testsite && php artisan schedule:run >> /home/me/output.txt

and all I get is:

No scheduled commands are ready to run.

The same task is working fine using Forge but not on my local environment.

I'm using ubuntu 18.04, laravel 5.8, php 7.3

Thank you for your help in advance

0 likes
15 replies
Nakov's avatar

Does running php artisan on your command line shows your custom command in the list?

MohammadAbusaleh's avatar

@NAKOV - yes, php artisan does show my custom command, also running it from the command line works fine as well. My code works fins on Forge, I just can't get it to run localy, so I have to setup the cronjobs manually instead of using Laravel Task Scheduler.

Nakov's avatar

@MOHAMMADABUSALEH - I don't understand the last part on your comment "I have to setup the cronjobs manually instead of using Laravel Task Scheduler". You should have them both, as your code above seems fine to me. The only other thing I can think of is checking on your command line if the crontab is running, so for example, check if crontab -l lists your command, and also to check if the cron daemon is running using ps -ef | grep crond

Snapey's avatar

if you ignore crontab for the moment, does php artisan schedule:run work from the command line?

MohammadAbusaleh's avatar

@NAKOV Thanks for your response, I meant I'm scheduling my commands from crontab like this:

* * * * * cd /home/me/Sites/booking.dits && php artisan integrity:check >> /home/me/output.txt

and the tasks are running, but I would like to use Laravel Task Scheduler:

 * * * * * cd /home/me/Sites/testsite && php artisan schedule:run >> /home/me/output.txt

but Laravel Task Scheduler only returns "No scheduled commands are ready to run."

Also to note: I tried some suggested stuff that I found online:

1- php artisan cache:clear

2- Try running the schedule ->withoutOverlapping()

3- $schedule->command('integrity:check')->cron('* * * * *')

MohammadAbusaleh's avatar

@SNAPEY - thanks for your response, It returns the same result:

'No scheduled commands are ready to run.'

Nakov's avatar

@MOHAMMADABUSALEH - The path to the projects in your examples above are different. Are you using the correct path?

On the first one you use /home/me/Sites/booking.dits and on the second /home/me/Sites/testsite.

Also just as a check in your Kernel add the full path to the command, for example:

protected $commands = [
        'App\Console\Commands\IntegrityCheck'
];
MohammadAbusaleh's avatar

@NAKOV - sorry the path thing was because I was typing from memory and I mis-typed it, but in the crontab file it is the correct one.

Also I used the full path to the command in my kernel and still "No scheduled command are ready to run".

Snapey's avatar
Snapey
Best Answer
Level 122

If you are having this problem from the command line, forget cron. Its a distraction.

If you have previously tried withoutOverlapping then you could have the mutex left behind so the scheduler is thinking it cannot start your task since an instance is already running.

This should be cleared by clearing the cache, but you say you tried this?

What sort of cache do you have?

If file based, anything in storage/framework/cache/data ?

2 likes
travisthomson's avatar

Thank you Snapey. You just saved the day for me. Had to clear the cache to get this running again.

MohammadAbusaleh's avatar

@SNAPEY - Yes I tried it but I cleared the cache after it, also I use redis as cache driver and I made sure mutex is not left behind.

Another thing to note, I created a fresh install of laravel with a test command and it is working fine. I'm assuming something is wrong with my current project but I don't know how to identify the problem.

MohammadAbusaleh's avatar

@snapey @nakov Thank you guys for the help, I appreciate you taking the time to do so, I deleted my vendor file, and deleted the whole storage folder, then everything started working fine.

Thanks again!

1 like
ekubischta's avatar

I wanted to comment for future users - The reason that deleting the whole storage folder "probably" worked is that you may have been stuck in a "down" state.

php artisan down will create a lockfile file called ./storage/framework/down When this is there, no commands will run (AND, in a very unhelpful way, does not tell you why)

So, running php artisan up will fix the issue

3 likes
bennettblack's avatar

After lots of headache - this post solved my problem. I didn't realize scheduled commands wouldn't run when the application is down. Chaining the evenInMaintenanceMode() method fixed my issue.

deGecko's avatar

@ekubischta Well, a year later, still no notice about this. I had an older installation on a server which I was trying to reuse now and apparently it was stuck in 'under maintenance mode' but I completely forgot about it.

Thank you very much!

Please or to participate in this conversation.