0

I'm trying to setup the cronjobs execution as I recently noted issues with the order mails not being sent due to the latest updates of Magento with mail handling. Specifically, I was trying to get the AOE Scheduler module working, which requires these configurations to be added on the crontab on the server:

AOE Scheduler instructions section

My problem is that I have no SSH access. My hosting admin panel offers though a way to execute periodically some URL.

Is there a way to get the cronjobs working through PHP?

1 Answer 1

2

Calling http://example.com/cron.php via URL is now forbidden by default, but you can enable it.

Here are the relevant lines in .htaccess (read the comments):

###########################################
## 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>

So 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 (which should work for you), replace

Deny from all

in your .htaccess file with

Allow from 127.0.0.1

Regarding Aoe_Scheduler: it uses a different script, shell/scheduler.php which is only executable via shell and gets called from scheduler_cron.sh. You could create a wrapper PHP script like this:

<?php
exec('scheduler_cron.sh --mode default');

Save it as /cron_default.php

and set up http://example.com/cron_default.php as URL to be executed. Create multiple scripts if you need different commands, don't pass GET parameters to a shell command.

Also I recommend to add the same protection to these files that Magento applies to cron.php and follow the steps above.

To protect all PHP files that start with "cron", replace

<Files cron.php>
    ...
</Files>

with

<FilesMatch "^cron.*\.php$">
    ...
</FilesMatch>
1
  • Thanks for the in-depth response. I will update as I try the solution.
    – gasper
    Apr 6, 2016 at 14:08

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