Getting cPanel cronjobs to work with Magento 1.9
Anybody here ever experienced issues getting the cron jobs to work with a Magento installation. Just installed the latest 1.9.2.3 and the cron jobs aren't working, even after adding them through the Cpanel.
So I have gone into my Cpanel (Magento 1.9.2.2) and have tried several different cron job calls. like
[LIST]
/usr/bin/php -f /home/exmaple/public_html/cron.php
php -f /home/example/public_html/cron.php
/bin/sh /home/example/public_html/cron.sh
I also have the AOE plugin installed. I have generated a schedule in the plugin and also went in my phpmyadmin and the cron table has a list of jobs that are "pending"
For the longest time it said no heart beat until I disables the htaccess file in the root directory where my magento store is installed. From there I can type in the url/cron.php and it will show a blank page but I begin to receive emails and when i refresh AOE it shows the cron jobs processed. The cron.php and sh files are set to 744. If I disable htaccess and manually access the php file...it works and that is as close as I have gotten to getting the system to function. When I bring back the htaccess file i get the 404 default magento screen and nothing gets processed. I'm not sure how to fix this?
-
You might do better to ask this over on the magento support site. I just did a quicky search and found this post that might be of some use to you: magecomp.com/blog/how-to-setup-a-cron-job-in-cpanel-for-magento/ 0 -
I think your cron job calls stopped working correctly because starting from some 1.9.*.* version Magento added an additional block to the .htaccess to increase cron.php file security: ########################################### ## Deny access to 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
As you can see, by default it blocks access to cron.php from any IP address. I suggest to: 1. Determine the IP address which your web server 'sees' when your cron.php is called. Find it in Raw Access logs in cPanel. 2. Modify the .htaccess file to allow access to cron.php from that IP address, change the above block in .htaccess to:########################################### ## Deny access to 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 Deny,Allow Deny from all Allow from 1.2.3.4
change 1.2.3.4 to the determined IP address from the Raw Access logs.0 -
Also, I suggest to use this command in cPanel Cron Jobs to call Magento cron: wget -O - -q 'http://www.yourdomain.com/cron.php'
change www.yourdomain.com to your Magento installation domain.0
Please sign in to leave a comment.
Comments
3 comments