"The crons need to be enabled" error - cPanel setup

I have been using crons successfully on v4 with the following style code in cPanel:
/usr/local/bin/php /home/seamless/public_html/clients/artisan ninja:send-reminders

Sadly when I use the following code (set to run every three minutes for troubleshooting purposes), I receive the red triangle error in the bottom left of the v5 dashboard “the crons need to be enabled.”
cd /home/seamless/public_html/clientsnew && /usr/local/bin/php -d register_argc_argv=On artisan schedule:run >> /dev/null 2>&1

I have tried a single “>” instead of “>>”, and a closing “/” after clientsnew, but the error persists.

I am waiting till this is resolved before importing data from v4.

If it’s useful, my cPanel gives the following as example code to run:
/usr/local/bin/php /home/seamless/public_html/path/to/cron/script

Is there any alternate configuration I can try?

@david do you have any suggestions?

this works on my cPanel

cd /path/to/root/folder && /usr/bin/php -d register_argc_argv=On artisan schedule:run >> /dev/null 2>&1

Note the scheduled task which checks whether the crons work is executed daily, so you may h ave a valid config, but it may take a day to check and update.

Thank you so very much for the input.

I also emailed my server support staff & they executed the command manually & without “>> /dev/null 2>&1” in order to see the output. The output was “No scheduled commands are ready to run” which gives the appearance that the command is executing correctly (right?)

So maybe the cron job is working. The only indicator I am going on is the red triangle in v5 indicating the error “the crons need to be enabled.”

Could it be that the red triangle is reporting incorrectly? As of now, I don’t have any content imported into v5, so I guess it has nothing to process. It’s just a bare installation with my username/password.

Thanks!

The only suggestion I have is to try to be explicit about php7.4, rather than just calling ‘php’ in your command, which is an alias for your default php version. This only really applies if your platform is running multiple versions of PHP or PHP-FPM, it’s a workaround. Other users have noticed it taking a while for the red ! alert to go away too.

Just a quick update to see if anyone can assist:

I now have a recurring invoice in v5. Next send date is Aug 2 & it has been “started.” (so there should be something for the cron to process).

When I execute the following command:

cd /home/seamless/public_html/clientsnew && /usr/local/bin/php -d register_argc_argv=On artisan schedule:run

I receive the output: “No scheduled commands are ready to run.”

Does this indicate a problem elsewhere than the cron? (& yes, the red triangle “the crons need to be enabled” is still lit up…)

Thanks!

I still seem to have problems with the “the crons need to be enabled” error.

Every time the cron job ticks over, I receive the output “No scheduled commands are ready to run.”

The red triangle on the bottom left of the back end continues to appear.

Is there any way to troubleshoot this, or to find a workaround?

@madumi,

are you using recurring invoices at all? are your scheduled tasks running? ie recurring invoices sending etc etc?

@david
Thanks for your message–sorry for the delay getting back to you.

Yes, I have for example a recurring invoices whose next send date is Sept 18,
and I have a non-recurring invoice whose next send date is Aug. 28

The recurring invoice is not being generated, and the non-recurring invoice doesn’t have reminders being sent out.

Each time the cron executes, I receive the output “No scheduled commands are ready to run.”

I am happy to try anything to troubleshoot or solve, I just need some direction what I might do.

It is good to note that manually running the command gives you the correct response. This indicates that the way you have configured the cron to run may need some adjustments as when the cron attempts it, it may be using a wrong path to either the PHP binary or the path to the artisan command.

@david
Thank you so much for your reply.

Even if I manually execute the code:

cd /home/seamless/public_html/clientsnew && /opt/alt/php73/usr/bin/php -d register_argc_argv=On artisan schedule:run

I also receive the output “No scheduled commands are ready to run”

Is there a way to troubleshoot what is going wrong?

V5 Cron Setup Guide - Debian 10.x Self-host - CLI Access req’d - Self-Hosted | v5 - Discourse (invoiceninja.com)
If you look at this user’s nice little guide under the header Cron Output Logs he shows an example of how to change the cron job ending so instead of piping to null, it appends the results to a log file, which can help you see the results of the cron job itself, so you can better tell if it is running.

I have personally had most luck putting the command directly into the /etc/crontab file, which requires you to specify the user:
* * * * * www-data /usr/bin/php7.4 /path/to/invoice/ninja/artisan schedule:run >> /dev/null 2>&1

@TechnicallyComputers
Thanks for your suggestion. Yes, I already am using a version of the command that lacks the >> /dev/null 2>&1 – so I am receiving the output from the command.

Each time the command runs, whether by cron, or from the command line, it gives the output “No scheduled commands are ready to run,” which is great, except that there are invoices & emails that need to go out, and are failing to go out (recurring invoices & invoice reminders).

I’m still struggling with the cron job and scheduled events in Invoice Ninja v5. Most recently, after upgrading to the lastest version, I am now receiving the following output from the cron job, even though scheduled events (eg. sending out invoice reminders) are still not working:
[2021-11-05T15:30:09+00:00] Running scheduled command: Callback
Does this offer any more insight what might be happening so I can fix this problem?

@david do you have any other ideas?

Hi Madumi,

There is something specific in your hosting configuration that appears to be the issue here,

[2021-11-05T15:30:09+00:00] Running scheduled command: Callback

references

$schedule->call(function () {
 Account::whereNotNull('id')->update(['is_scheduler_running' => true]);
})->everyFiveMinutes(); 
            

This command is what helps us determine whether your crons are configured and are executing correctly. It sounds like the cron is definitely working, however something else in the hosting stack is preventing the actual command from running.

I’m not sure I can offer more help that this other than to note that I have my own cPanel shared hosting account and cannot recreate this issue, so it may be something specific to your webhosts server configuration

@madumi

In your very first post you wrote you set the cron job to run every three minutes. AFAIK it really needs to run every minute. So, if your cron job says something like

*/3 * * * * www-data /usr/bin/php7.4 /path/to/invoice/ninja/artisan schedule:run >> /dev/null 2>&1

you need to change to

* * * * * www-data /usr/bin/php7.4 /path/to/invoice/ninja/artisan schedule:run >> /dev/null 2>&1

1 Like

Hi @david

I have been corresponding with my server tech support & attempting to determine what might differ in my cPanel installation. All of the listed IN software requirements are met (Free Source Available Invoicing, Expenses & Time-Tracking | Invoice Ninja). & I am using PHP 7.4… yet scheduled invoices/emails are not being sent.

Is there a working installation I/tech support could somehow compare the software running in my server with to see what might differ? Or any other way to narrow this problem down? If an IN admin would like to check my IN backend settings, I can provide a login.

Thanks!

@madumi,

One thing to try is to configure webcrons

https://invoiceninja.github.io/docs/self-host-troubleshooting/#webcron-configuration

If the system still does not send emails, then your webhost has disabled the required functions to execute schedule:run which is what the crons are attempting to run also

all is good now - Thank you very much