Magento – Magento 1.9.1 cron_schedule is not picked for ever

ce-1.9.1.0cronschedule

I spent almost 3 days and cant able to understand and make the Magento Cron to process the scheduled tasks. I am running Magento 1.9.1.0 and recently noticed that order emails are now queued instead of sending instantly. I understand the necessacity but cant able to make the system to pick the queues.

Here is my seeing for Cronjob.
enter image description here

Here is my cronjob command line.
enter image description here

Here is how the tasks are created in cron_schedule table.
enter image description here

Since the records are created in cron_schedule table i think the Cron is running once in every 5 minutes. If I manually delete these records via PhpMyAdmin the records are created automatically after some time.

But the status of the tasks remains 'pending' and never complete. Not sure if something wrong in my configuration or I am missing anything. Can someone please help me how to make the scheduled task run on time. Also why multiple records are created for one job code?

Update

I cleared the entire table and the cron created the scheduled jobs. All the jobs are in pending state and never run even waiting more than 60 minutes. Something is wrong in Magento 1.9.1

Update 11/02: Today I did some more analysis on the process.

I edited the cron.php as below

echo 'iam before mdefault 1';
shell_exec("/bin/sh $baseDir/cron.sh $fileName -mdefault 1 > /dev/null 2>&1 &");
echo 'iam before malways 1';
shell_exec("/bin/sh $baseDir/cron.sh $fileName -malways 1 > /dev/null 2>&1 &");
echo 'i returned success';

I edited the Mage_Cron_Model_Observer class as below

public function dispatch($observer) {
  echo 'iam inside dispath';

My understanding was when the cron runs the -mdefault it should call the dispatch function and the execute will happen. But what happened was as below in the cron output.

Content-type: text/html

iam before mdefault 1iam before malways 1i returned success

It means the dispatch doesn't called atall…

One another try

I manually changed the variable $isShellDisabled = true; and I changed the below in cron.php.

if ($isShellDisabled) {
  echo 'before always';
  Mage::dispatchEvent('always');
  echo 'after always';
  Mage::dispatchEvent('default');
  echo 'after default';
} else {
  Mage::dispatchEvent($cronMode);
}

The cron output for the above is as below

Content-type: text/html

before alwaysiam inside dispath alwaysafter always

Now it calls the 'dispatchAlways' but not the 'dispatch'

None of the answers helps me. It never picks the scheduled tasks. I.e when the Cron runs for the first time it successfully created the tasks in the table. But it never executes the task.

Best Answer

It was the PHP version of Cron Jobs.

The PHP version was set correctly for the site which is why it was working; however Cron Jobs was running at server native PHP 5.3 which is why I was getting the errors only when running Cron. I updated to version 5.5.

Changed Cron command:

php /home/mydomainname/public_html/cron.php
to
php55 /home/mydomainname/public_html/cron.php

or in hostgator:

/opt/php55/bin/php /home/mydomainname/public_html/cron.php

in cron.php

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

After this line, add:

$isShellDisabled = true;