0

I just set cron job using cpanel of my site,

according to that cron.php runs in every 5 mins.

But it's not. It is working whenever I execute cron.php directly from browser.

Here is the code of my cron.php :

chdir(dirname(__FILE__));
require 'app/bootstrap.php';
require 'app/Mage.php';
if (!Mage::isInstalled()) {
    echo "Application is not installed yet, please complete install wizard first.";
   exit;
}
// Only for urls
// Don't remove this
$_SERVER['SCRIPT_NAME'] = str_replace(basename(__FILE__), 'index.php', $_SERVER['SCRIPT_NAME']);
$_SERVER['SCRIPT_FILENAME'] = str_replace(basename(__FILE__), 'index.php', $_SERVER['SCRIPT_FILENAME']);
Mage::app('admin')->setUseSessionInUrl(false);
umask(0);
$disabledFuncs = explode(',', ini_get('disable_functions'));
$isShellDisabled = is_array($disabledFuncs) ? in_array('shell_exec', $disabledFuncs) : true;
$isShellDisabled = (stripos(PHP_OS, 'win') === false) ? $isShellDisabled : true;
$isShellDisabled = true;
try {
    if (stripos(PHP_OS, 'win') === false) {
        $options = getopt('m::');
        if (isset($options['m'])) {
            if ($options['m'] == 'always') {
                 $cronMode = 'always';
            } elseif ($options['m'] == 'default') {
                 $cronMode = 'default';
            } else {
                 Mage::throwException('Unrecognized cron mode was defined');
             }
        } else if (!$isShellDisabled) {
            $fileName = escapeshellarg(basename(__FILE__));
            $cronPath = escapeshellarg(dirname(__FILE__) . '/cron.sh');

            shell_exec(escapeshellcmd("/bin/sh $cronPath $fileName -mdefault 1 > /dev/null 2>&1 &"));
            shell_exec(escapeshellcmd("/bin/sh $cronPath $fileName -malways 1 > /dev/null 2>&1 &"));
            exit;
        }
    }
    Mage::getConfig()->init()->loadEventObservers('crontab');
    Mage::app()->addEventArea('crontab');
    if ($isShellDisabled) {
        Mage::dispatchEvent('always');
        Mage::dispatchEvent('default');
    } else {
        Mage::dispatchEvent($cronMode);
    }
} catch (Exception $e) {
    Mage:: printException($e); //Please remove space after Mage:: p
    exit(1);
}

enter image description here

please check and let me know why its not working or call automatically, no mail send to customers when they purchase any product.

  • Change command to php -q /home1/shoppjb2/public_html/cron.php – Ahmed Elawadi May 26 '16 at 9:13
  • I already try this, but not working for me no mail received or no error in exception file. – Yogita May 26 '16 at 9:25
  • @Marius When i tried this php /home1/shoppjb2/public_html/cron.php I have got an email each time when cron executed i.e. Status: 500 Internal Server Error Content-type: text/html – Yogita May 26 '16 at 9:29
2

Issue Solved I just changed php /home1/user_name/public_html/cron.php to /usr/php/54/usr/bin/php -q /home1/user_name/public_html/cron.php. Here 54 is my hostserver php version.

0

PHP command examples:

General example: /usr/local/bin/php /home/foohe82gflhl/public_html/path/to/cron/script

Domain-specific example: /usr/local/bin/ea-php56 /home/foohe82gflhl/domain_path/path/to/cron/script

My Specific Working Solution:

/usr/local/bin/php /home/foohe82gflhl/public_html/balrajeshwar/get99acerslead.php

Description: php path your specific folder location where php file exist

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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