The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Getting cPanel cronjobs to work with Magento 1.9

Discussion in 'General Discussion' started by the_Dsigner, Feb 10, 2016.

  1. the_Dsigner

    the_Dsigner Active Member

    Joined:
    Jan 2, 2014
    Messages:
    43
    Likes Received:
    1
    Trophy Points:
    8
    Location:
    Montreal, Canada
    cPanel Access Level:
    Website Owner
    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



    • /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?
     
  2. Infopro

    Infopro cPanel Sr. Product Evangelist
    Staff Member

    Joined:
    May 20, 2003
    Messages:
    14,463
    Likes Received:
    195
    Trophy Points:
    63
    Location:
    Pennsylvania
    cPanel Access Level:
    Root Administrator
    Twitter:
    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/
     
  3. Avensen

    Avensen Member

    Joined:
    Feb 27, 2007
    Messages:
    15
    Likes Received:
    1
    Trophy Points:
    1
    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:

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

    Code:
    ###########################################
    ## 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 Deny,Allow
        Deny from all
        Allow from 1.2.3.4
    
      </Files>
    
    change 1.2.3.4 to the determined IP address from the Raw Access logs.
     
    #3 Avensen, Feb 12, 2016
    Last edited: Feb 12, 2016
  4. Avensen

    Avensen Member

    Joined:
    Feb 27, 2007
    Messages:
    15
    Likes Received:
    1
    Trophy Points:
    1
    Also, I suggest to use this command in cPanel Cron Jobs to call Magento cron:

    Code:
    wget -O - -q 'http://www.yourdomain.com/cron.php'
    
    change www.yourdomain.com to your Magento installation domain.
     
    #4 Avensen, Feb 12, 2016
    Last edited: Feb 12, 2016
Loading...

Share This Page