cancel
Showing results for 
Search instead for 
Did you mean: 

Cron.php/Cron.sh Not being called - Permission problem

Cron.php/Cron.sh Not being called - Permission problem

Yes I know another Cron problem with version 1.9, but I honestly have looked through so many posts here and on stack.esxchange and I have gotten nowhere.

 

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 644.  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?

 

13 REPLIES

Re: Cron.php/Cron.sh Not being called - Permission problem

644 means that you file is read-write for owner and read for everyone else. Basically your cron.sh would look like this when those permissions are applied.

-rw-r--r-- 1 pronto pronto 0 Feb 10 00:09 cron.sh

It also means that this file never gets executed as it doesn't have execution rights. If you're trying to run this script under your own crontab, you should use 744 permissions instead:

-rwxr--r-- 1 pronto pronto 0 Feb 10 00:09 cron.sh

Please note that php -f /home/example/public_html/cron.php tries to run cron.sh anyway, so you pretty much need to change permissions so that it is executable.

Tanel Raja

Re: Cron.php/Cron.sh Not being called - Permission problem

Hi,

 

I changed the permissions of both the cron.php and cron.sh to permission 744 and its been an hour and AOE is still showing no heartbeat. When I manually type in the url/cron.php it won't execute...only if my htaccess has been disables will it manually execute and show up as working in the AOE Scheduler listing...

Re: Cron.php/Cron.sh Not being called - Permission problem

This is what is contained in my htaccess file:

 

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

 

Could this be blocking my cron.php file from being executed by the Cpanel?

Re: Cron.php/Cron.sh Not being called - Permission problem

Only when called from outside using HTTP URL (which you shouldn't do anyway).

Tanel Raja

Re: Cron.php/Cron.sh Not being called - Permission problem

Then it still not being called for.some reason I'm internally...

Re: Cron.php/Cron.sh Not being called - Permission problem

I'm not sure it's called at all. I guess there should be some kind of cron log or error messaging system to analyse that. Maybe you should add a line to cron.php that send you e-mail to confirm that it's called?

Tanel Raja

Re: Cron.php/Cron.sh Not being called - Permission problem

I managed to write a mail-to in the cron call to send a notification of what was going on, and in the email I'm getting this error

 

PHP:  syntax error, unexpected '(' in /usr/local/lib/php.ini on line 3
X-Powered-By: PHP/5.5.31
Content-type: text/html

<br />
<b>Fatal error</b>:  Uncaught exception 'Zend_Db_Adapter_Exception' with message 'The PDO extension is required for this adapter but the extension is not loaded' in /home/kegel4/public_html/lib/Zend/Db/Adapter/Pdo/Abstract.php:344
Stack trace:
#0 /home/kegel4/public_html/lib/Zend/Db/Adapter/Abstract.php(248): Zend_Db_Adapter_Pdo_Abstract-&gt;setFetchMode(2)
#1 /home/kegel4/public_html/app/code/core/Mage/Core/Model/Resource.php(175): Zend_Db_Adapter_Abstract-&gt;__construct(Array)
#2 /home/kegel4/public_html/app/code/core/Mage/Core/Model/Resource.php(110): Mage_Core_Model_Resource-&gt;_newConnection('pdo_mysql', Object(Mage_Core_Model_Config_Element))
#3 /home/kegel4/public_html/app/code/core/Mage/Core/Model/Resource/Db/Abstract.php(320): Mage_Core_Model_Resource-&gt;getConnection('core_write')
#4 /home/kegel4/public_html/app/code/core/Mage/Core/Model/Resource/Db/Abstract.php(350): Mage_Core_Model_Resource_Db_Abstract-&gt;_getConnection('write')
#5 /home/kegel4/public_html/app/code/core/Mage/Core/Model/Resource/Db/Abstract.php(335): Mage_Core_Mo in <b>/home/kegel4/public_html/lib/Zend/Db/Adapter/Pdo/Abstract.php</b> on line <b>344</b><br />

 

Re: Cron.php/Cron.sh Not being called - Permission problem

What's that error with php.ini? Also make sure that your fpm and cli use same ini file. I've seen hostings where cli and fpm fun totally different versions of php.

Tanel Raja

Re: Cron.php/Cron.sh Not being called - Permission problem

Do you have SSH Access for your hosting account? 

 

If you don't, you may need to edit the cron.php file and look for the following line of codes:-

$isShellDisabled = (stripos(PHP_OS, ‘win’) === false) ? $isShellDisabled : true;

Add the following codes in a new line exactly after the above line of codes:-

$isShellDisabled = true;

 

James Lee | Moderator • Magento Master
See My Recommended Magento Hosting & Security Tips