2

I am using 1.9.2.1. After applying SUPEE-6788 , cron stopped working. Why?? I attached the cron setting of my system.

enter image description here

1 Answers1

5

You probably set up your cronjob to call cron.php via HTTP, which is now forbidden by default.

This is the new rule in .htaccess:

###########################################
## Deny access to cron.php
    <Files cron.php>

############################################
## uncomment next lines to enable cron access with base HTTP authorization
## http://httpd.apache.org/docs/2.2/howto/auth.html
##
## Warning: .htpasswd file should be placed somewhere not accessible from the web.
## This is so that folks cannot download the password file.
## For example, if your documents are served out of /usr/local/apache/htdocs
## you might want to put the password file(s) in /usr/local/apache/.

        #AuthName "Cron auth"
        #AuthUserFile ../.htpasswd
        #AuthType basic
        #Require valid-user

############################################

        Order allow,deny
        Deny from all

    </Files>

The best solution would be to not call the cron like that. If your system crontab looks like this:

* * * * * wget http://example.com/cron.php

Change it to something like this:

* * * * * php /path/to/magento/cron.php -mdefault
* * * * * php /path/to/magento/cron.php -malways

If for some reasons you cannot use a regular cronjob and need to call it via HTTP, you should either make it password protected as described in the comments above, or add an IP whitelist to only allow access from localhost (or the IP which triggers your cronjob)

For example, to allow access from localhost, replace

Deny from all

in your .htaccess file with

Allow from 127.0.0.1

Update based on screenshot

Your screenshot shows something entirely different than your first comment. This is some web based cron management, where you cannot specify the crontab directly with cron syntax. Maybe you can choose an option other than "http" and "https" in the first dropdown to actually specify a path but probably not, so this is one of the cases where you cannot use a regular cronjob.

Luckily your web interface allows using password authentication (see advanced settings), so you can follow the instructions in the htaccess file to create a .htpasswd password file.

Fabian Schmengler
  • 65,791
  • 25
  • 187
  • 421
  • I use */5 * * * * /bin/sh /path/to/magento/cron.sh cron.php -m=default. Is this going to achieve the same goal? – MW Millar Oct 30 '15 at 09:41
  • This is fine and should not have stopped the cron from working... – Fabian Schmengler Oct 30 '15 at 09:43
  • Where exactly do I need to put * * * * * php /path/to/magento/cron.php -mdefault
            • php /path/to/magento/cron.php -malways ? I attached the cron setting of our system.
    –  Oct 30 '15 at 09:55
  • So I should uncomment and adjust #AuthName "Cron auth" #AuthUserFile ../.htpasswd #AuthType basic #Require valid-user these ones, and delete Order allow,deny Deny from all these ones? –  Oct 30 '15 at 10:53
  • Yes, after you generated a .htpasswd file with user name and password and entered these in your cronjob settings. – Fabian Schmengler Oct 30 '15 at 10:57
  • Are both -mdefault and -malways needed? Or either one? When I run "/usr/bin/php /path/to/magento/cron.php" manually from ssh, it works. But putting the same command on cPanel Cron Job doesn't work. The command is executed, but nothing happens. Any idea? – Shawn Nov 05 '15 at 19:31
  • In the core, the "always" mode is only used by enterprise modules but to be on the safe side I'd always set up both – Fabian Schmengler Nov 05 '15 at 19:37
  • I updated my comment. I can't get it to work. The command ran fine on SSH, but not working when on cPanel Cron Job. Any idea? Also, from cron.php, it seems without specifying any mode at the end, it runs both modes by default? – Shawn Nov 05 '15 at 19:41
  • It tries to spawn two processes for both modes but will not show you any error if it does not work, so I prefer to run both explicitly. No idea what else can be wrong in your configuration – Fabian Schmengler Nov 05 '15 at 19:48
  • /usr/bin/php command doesn't work, but /bin/sh works. However the cron jobs run by /bin/sh are slightly delayed. Is that normal? – Shawn Nov 05 '15 at 20:06
  • Slightly, if you call it without parameters. Again, you should append -mdefault and -malways, otherwise cron.sh calls cron.php which calls cron.sh twice, which calls cron.php and each call to cron.php initializes the Magento app. – Fabian Schmengler Nov 05 '15 at 20:35