Skip to content
Advertisement

Cronjob not running php script

I’ve done some searching before this post and I still can’t seem to get this to work. I’m trying to setup a cron job with PHPMailer to send out an email every so often. The script below does work if I run it manually but does not work in the cron job scheduler.

For this example – I set it to run every minute. I’m thinking it has to do something with the “vendor/autoload.php” and it’s path not loading correctly? I didn’t add my SMTP credentials with api key for security reasons as well as recipients for this post.


Here is my cron job setup in Cpanel. enter image description here


Here is my PHPMailer code:

JavaScript

If anyone could help me, I would really appreciate it!

Advertisement

Answer

Can you share you error-message with us? I assume this will help a lot to find the issue.

I’ve shared my insights how to enable logging in a different post on stack overflow (see link below). This will explain how you can display errors in your cron execution:

https://stackoverflow.com/a/60250715/12880865

Please let me know if this helps you. If you’ll get a proper error message, please share it with us so we can dig further into your question.

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement