I have setup cron job, it is working properly, however when i directly runs the php file(from the path/url) it successfully runs, but from cron its not. However i set another very simple file to make sure my cron command/path is set correctly i created another file and used simple php mail function and its is running successfully. Kindly suggest me the possible areas to look into it. (I am using Cpanel)
In cPanel, select Cron Jobs in the Advanced section of the Main Page menu. You will find a table for adding new scripts and setting their time intervals. To simplify configuration, we include a drop-down menu with common settings such as Once Per Week or Once Per Month.
If you are still suspecting a problem with the cron job, then there are normally 3 possibilities why it might not be running: The cron daemon (the system process that runs cron jobs) could not run the script or was unable to send an email There were issues with the mail server mailing the output or the email was lost
You may also need to go through the mail server log to double-check if there was an attempt to send an email after the completion of the cron job. Remember that the designated email address is set near the top of the cron job page in cPanel. You can use the email address to isolate the mail attempts in the mail server log.
When your cron job has been set up, you will see a success message. Scroll down to the “Current Cron Jobs” section. Click the “Edit” or “Delete” link. “Edit” will bring up the cron job settings. Make any necessary changes and click the “Edit Line” button. “Delete” will open a delete dialog.
Instead of putting in cronjob command like
php -f /path_to_script/script.php
put command like this:
curl http://domain.com/yourscript.php
if you want to suppress output you can add > /dev/null
at the end.
So full command would be:
curl http://domain.com/yourscript.php > /dev/null
Hope this helps!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With