1
votes

I'm getting an issue with setup cron on my Cpanel. I have added a new file mail.php to send an email. And from Advance > Cron Jobs I added the following command to run it every minute.

/usr/local/bin/php /home/USER/public_html/cron/mail.php

But its not working. Do I need anything else for that?

Please help.

Thanks

Edit:

Image for Cpanel

2
Try like this: php /usr/local/bin/php /home/USER/public_html/cron/mail.php if above not working than try like this : php /home/USER/public_html/cron/mail.php - Mahendra Pumbhadiya
And for run cron on every minute you have to set minute=*,hour=*,day=*,month=*,weekday=* - Mahendra Pumbhadiya
Thanks for reply. I tried both but noting happen :( - Novac Redclif
what is your hosting server provider? did you tried to fired your mail.php directly from address bar? - Mahendra Pumbhadiya
Yes. When I try to access directly, then its working good. So I just need to use it with schedule from Cpanel Cron Job. - Novac Redclif

2 Answers

0
votes

Try like this,

php /home/USER/public_html/cron/mail.php

check below screenshot once how to set cron job enter image description here

also pls double check /home/USER is your root directory? if not than cron job will not running. and some of the hosting provider's cron job command is different.

IMPORTANT THINGS TO BE REMEMBER REGARDING CRON JOB

  1. -first check you are able to run your cron job on every minute, some basic charge of your server, from my thinking you are not able to fired cron on every minute and some of not giving you to fired your cron on every minute.
  2. if every minute not working than try to run command for 15 or every 30minutes than only you know whether your cron job is running
  3. first ask to your hosting provider regarding can i able to fired my cron on every minute.

Look Some Example:

//Command to run a PHP5 cron job:
php /home/user_name123/public_html/cron.php
OR
usr/local/php5/bin/php5 /home/user_name123/public_html/cron.php


//Optional flag sometimes required for a PHP cron job:
php -q /home/user_name123/public_html/cron.php

//Command to run a PHP4 cron job:
/usr/local/php4/bin/php /home/user_name123/public_html/cron.php
0
votes

Your syntax seems correct but the php path might be wrong. For linux it's normally /usr/bin/php,

To find out the correct php path, login to your server using ssh and run the following command,

whereis php

or

whereis php5

And use this path in your cronjob command. Also, run this command in terminal using ssh to make sure it is correct and working without any error.