Cron job is not working properly in cpanel

13,134

Solution 1

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!

Solution 2

As alternative to cURL, you can call your script through text-based browser. Something like this:

lynx -dump http://localhost/script.php
Share:
13,134
Manoj
Author by

Manoj

Updated on June 19, 2022

Comments

  • Manoj
    Manoj almost 2 years

    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)