0

I'm after some advice if possible

Since upgrading to 1.9.1 as per a lot of other people emails are not sending from the queue.

The emails are being generated and placed in the core_email_queue table absolutely fine however the processed time remains unchanged and the emails never leave this table. Shipping emails are sent fine as these are not added to the queue so it is not a mail setting.

I am using AOE scheduler to check the cron settings, the schedule is working fine and my cron is running as things such as backup and log clearing is working fine also. running mydomain/cron.php also does not send the mail from the queue.

Other than bypassing the email queue has anyone got any suggestions? below is a copy of my cron.php, the only amendment is the following line which was added on line 49 as initially the cron file wasn't running.

$isShellDisabled = true;


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 = basename(__FILE__);
            $baseDir = dirname(__FILE__);
            shell_exec("/bin/sh $baseDir/cron.sh $fileName -mdefault 1 > /dev/null 2>&1 &");
            shell_exec("/bin/sh $baseDir/cron.sh $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);
    exit(1);
}


?>

The key thing is the emails are being added to the table correctly but not being processed when the cron script runs. Also below is a couple of images of the core_email_queue and cron_schedule tables

cron.sh script

#!/bin/sh
# location of the php binary
if [ ! "$1" = "" ] ; then
    CRONSCRIPT=$1
else
    CRONSCRIPT=cron.php
fi

MODE=""
if [ ! "$2" = "" ] ; then
    MODE=" $2"
fi

PHP_BIN=`which php-5.3`

# absolute path to magento installation
INSTALLDIR=`echo $0 | sed 's/cron\.sh//g'`

#   prepend the intallation path if not given an absolute path
if [ "$INSTALLDIR" != "" -a "`expr index $CRONSCRIPT /`" != "1" ];then
    if ! ps auxwww | grep "$INSTALLDIR$CRONSCRIPT$MODE" | grep -v grep 1>/dev/null 2>/dev/null ; then
        $PHP_BIN $INSTALLDIR$CRONSCRIPT$MODE &
    fi
else
    if  ! ps auxwww | grep "$CRONSCRIPT$MODE" | grep -v grep | grep -v cron.sh 1>/dev/null 2>/dev/null ; then
        $PHP_BIN $CRONSCRIPT$MODE &
    fi
fi

I am currently calling the cron.php via the following at the advice of my web hosting provider

*/5 * * * * /usr/bin/wget -O /dev/null -q http://www.mydomain.co.uk/cron.php > /dev/null
8
  • Is the cron running as the same user as your webserver (www-data, apache, nginx etc). Commented Mar 9, 2015 at 13:10
  • What Cags said. And also try using cron.sh since it will only run a single instance of cron at a time. This helps me to isolate other tasks causing problems.
    – ladle3000
    Commented Mar 9, 2015 at 13:15
  • Hi thanks, I've tried this and it works the same also, I've attached the cron.sh script above, fyi the crontab command is: */5 * * * * /usr/bin/wget -O /dev/null -q mydomain.co.uk/cron.php > /dev/null Commented Mar 9, 2015 at 13:23
  • The following is the advice i've received from the host about the webserver user "It's printcar1 - you're on shared hosting so each site runs under its own user. Your FTP users also use the same unix user ID despite having various virtual logons." Commented Mar 9, 2015 at 13:33
  • Remove dev null if you want to get logging sent
    – ladle3000
    Commented Mar 9, 2015 at 14:55

0