Cron 403 - Forbidden Error

Hello,
I’m new to InvoicePlane. I have it installed in a subdirectory and it seems to work great. I can send invoices manually and modify templates just fine. I’m having trouble getting the Cron Job going however. I am using v1.6.1. No matter how I set up the cron job I get an error message: Status code: 403 - Forbidden.

The instructions I’ve been able to find say to set the cron using the following string:http://your-domain.com/invoices/cron/recur/your-cron-key-here. The trouble with this is that the directories in this example don’t exist in my installation. I searched through the directories and located Cron.php here: https ://mydomain.com/invoice/application/modules/invoices/controllers/Cron.php.

I have set up a cron job using this path and entered the cron key given in System Settings as such:
https : //mydomain.com/invoice/application/modules/invoices/controllers/Cron.php/aXhCUM1oc34r8gAu.

I have read that you need to include /index.php in the string which I have also tried with no success. In the ipconfig.php have set it to remove the index.php from the URL: REMOVE_INDEXPHP=true

My htaccess file is setup as such:

### InvoicePlane htaccess

<IfModule mod_rewrite.c>
  RewriteEngine On
  
  ### uncomment to force HTTPS
   RewriteCond %{HTTPS} off
  RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [R=301,L]
  RewriteRule ^index\.php$ - [L]
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  ### uncomment and adjust if installed in subdirectory
  RewriteRule . /invoice/index.php [L]
  RewriteRule . /index.php [L]
</IfModule>

I hope someone can help me to figure this out. Other than getting the cron to work the software seems great. I would like to contribute to the developers if I am able to get it working as it should.
Thank you, Ray

1 Like

Hi Ray,
Great job on the question.
Let me explain something about https : //mydomain.com/invoice/application/modules/invoices/controllers/Cron.php/aXhCUM1oc34r8gAu

So in an application like InvoicePlane, we’re not directly accessing application/modules/invoices/controllers/Cron.php, by going to invoices/recur/cron the application knows to look in the invoices module, Cron controller.

It then receives the cron key and determines if it wants to start that cron.
In your case it doesn’t because of that error.

I don’t think the application reaches that Cron controller, because of the 403 error.

Open your application/logs see if there’s a log in there

Hello UnderDog,
Thank you for the super fast response!

I have modified the cronjob as you suggested (I think):
https://mydomain.com/invoice/invoices/recur/cron/aXhCUM1oc34r8gAu - but now get the following message in the email notification:

/bin/bash: https://mydomain.com/invoice/invoices/recur/cron/aXhCUM1oc34r8gAu: No such file or directory

Please note, this cronjob is written in the cPanel Cron Jobs tool. I have also put it in the crontab via terminal in WHM but have not figured how to get email notifications to be sent from that interface. I’ve tried suggestions offered on the web without success. I don’t know if a cronjob entered in the crontab file works differently than one in the cPanel tool?

I appreciate your help!
Ray

It’s the local server, so shouldn’t it then be:
/bin/bash: /var/www/path/to/invoiceplane/invoice/invoices/recur/
The problem is, that this cronjob should kick off a PHP script and with /bin/bash it looka like it’s kicking off a bash script

Hi Again UnderDog,

I have several cron jobs running and none of them generate the /bin/bash: prefix in the email output. I use Moodle on my server for several companies and the cron job for them looks like this:
/usr/local/bin/ea-php81 /home/myserver/public_html/bbay/admin/cli/cron.php

I formatted the InvoicePlane similarly but still got No such file or directory as a result.

I also attempted formatting as your last message suggested and again get No such file or directory.

I tried formatting the cron this way:
/usr/local/bin/ea-php81
var/www/mydomain.com/invoice/invoices/recur/cron/aXhCUM1oc34r8gAu - I got htis email response: Could not open input file: /var/www/mydomain/invoice/invoices/recur/cron/aXhCUM1oc34r8gAu

Maybe I’m getting closer?!

I really appreciate you trying to help me resolve this. :smiley:

Ray

I am still unable to get the cron working with InvoicePlane. Are there anymore suggestions out there?

Thank you in advance, Ray

1 Like

Hello @raypierce,

where is your cron job pointing? the url you posted is wrong. The InvoicePlane cron url is https://<MY-DOMAIN>/invoices/cron/recur/<MY-CRON-KEY>. The url you posted has a “invoice” too much (but it might be right if InvoicePlane is installed in a subdirectory).

To debug, follow this steps:

  • If you visit the cron url with a web browser, what is shown on the browser?
  • Check the logs of your webserver (Apache or Nginx) and see what is shown (after you visited the url with your browser).
1 Like