Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

Magento 1.4.0.1 - Cronjobs executed multiple times
 
mwltr
Jr. Member
 
Avatar
Total Posts:  17
Joined:  2007-12-27
Würzburg
 

Hi,

I recently had a problem, that some Cronjobs were started several times.
Especially Cronjobs that need more time than 5 minutes.

So the reason for the multiple execution was, that a Cronjob is executed but is not set to status “running”.
When the next Cronjob is triggerd by the OS the Job ist executed again because the status is still pending.

If you have the same problem, here is how I fixed it:
Copy the Mage/Cron/Model/Schedule.php from core folder to community with the same folder-layout.
Replace the function “tryLockJob” with the following code:

public function tryLockJob()
    
{
        $result 
= ($this->_getResource()->trySetJobStatusAtomic($this->getId(), self::STATUS_RUNNINGself::STATUS_PENDING));
        if(
$result{
            $this
->setStatus(self::STATUS_RUNNING);
        
}
        
return $result;
    
}

Thats it, now Crons are working again.

Matthias

 
Magento Community Magento Community
Magento Community
Magento Community
 
dvmada
Jr. Member
 
Avatar
Total Posts:  23
Joined:  2008-06-18
Antananarivo, Madagascar
 

Thanks, Work fine now smile

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top