0

When i run cron.php like http://www.YOURDOMAIN.com/PATH_TO_MAGENTO/cron.php on my local server wamp i get a white page which means is runs properly.

But when i run on my remote server i get magento page saying There was no 404 CMS page configured or found.

This means cron.php isn't running properly?

I'm running cron.php via cronjob in my cpanel like this /opt/alt/php56/usr/bin/php /home/path/to/magento/cron.php >> /home/path/to/magento/var/log/cron.log.

Update:

Including $isShellDisabled = true; make it work with cronjob /opt/alt/php56/usr/bin/php /home/path/to/magento/cron.php >> /home/path/to/magento/var/log/cron.log. Then i changed cronjob to /bin/sh /home/path/to/magento/cron.sh > /home/path/to/magento/var/log/cron_sh.log and it also works.

2 Answers 2

1

Cron.php file not excute from browser because it is restricted from .htaccess file. You can comment the below two lines in .htaccess file at the bottom, then it will work.

<Files cron.php>
    #Order allow,deny
    #Deny from all
</Files>

You can also add the below line in cron.php file

$isShellDisabled = true; 

after the below code:

$isShellDisabled = is_array($disabledFuncs) ? in_array('shell_exec', $disabledFuncs) : true;
$isShellDisabled = (stripos(PHP_OS, 'win') === false) ? $isShellDisabled : true;
1
  • Seems like its working after making the change. I also removed another cronjob it was there php -f /home/path/to/magento/cron.php. I guess the other cronjob wouldn't be the problem. Thanks for saving my day. Commented Apr 21, 2017 at 10:33
0

First of all i dont know why its showing 404 page. Rather it should show

You don't have permission to access /cron.php on this server. Apache/2.4.23 (Win64) PHP/5.6.25 Server at domain.magento.com Port 80

Because if you open .htaccess file in magento root you will find this

###########################################
## Deny access to cron.php
    <Files cron.php>
       Order allow,deny
       Deny from all
    </Files>

Its good because no one should access cron.php file through browser.

Now the most important part is... you should never run cron.php file through browser. Rather run cron.sh. This file also calls cron.php internally. And this wont start running again if its already running which cron.php does.

5
  • Is cron.sh called the same way? /opt/alt/php56/usr/bin/php /home/path/to/magento/cron.sh >> /home/path/to/magento/var/log/cron.log Commented Apr 21, 2017 at 10:38
  • No. Its not a php file. Its a .sh file. So the command is sh cron.sh Commented Apr 21, 2017 at 10:39
  • I think it should be /bin/sh. I'm executing via Cpanel cronjob. Commented Apr 21, 2017 at 11:02
  • May be yes. Depends on your server. Commented Apr 21, 2017 at 11:07
  • I'm using /bin/sh /home/path/to/magento/cron.sh > /home/path/to/magento/var/log/cron_sh.log and it's running. Thank you very much. Commented Apr 21, 2017 at 11:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.