public function checkRunningJobs()
    {
        $maxJobRuntime = intval(Mage::getStoreConfig(self::XML_PATH_MAX_JOB_RUNTIME));

        if ($maxJobRuntime) {
            foreach ($this->getAllRunningSchedules(gethostname()) as $schedule) { /* @var $schedule Aoe_Scheduler_Model_Schedule */
                // checking if the job isn't running too long
                if ($schedule->isAlive()) {
                    if ($schedule->getDuration() > $maxJobRuntime * 60 && !$schedule->getKillRequest()) {
                        $schedule->requestKill(null, 'Kill requested because job exceeded the max job runtime of ' . $maxJobRuntime . ' minutes.');
                    }
                }
            }
        }

        // fallback (where process cannot be checked or if one of the servers disappeared)
        // if a task wasn't seen for some time it will be marked as error
        $markAsErrorAfter = intval(Mage::getStoreConfig(self::XML_PATH_MARK_AS_ERROR));
        $maxAge = time() - min($markAsErrorAfter, 5) * 60;
        if ($markAsErrorAfter) {
            $schedules = Mage::getModel('cron/schedule')->getCollection()/* @var $schedules Mage_Cron_Model_Resource_Schedule_Collection */
            ->addFieldToFilter('status', Aoe_Scheduler_Model_Schedule::STATUS_RUNNING)
                ->addFieldToFilter('last_seen', array('lt' => strftime('%Y-%m-%d %H:%M:00', $maxAge)))
                ->load();

            foreach ($schedules as $schedule) { /* @var $schedule Aoe_Scheduler_Model_Schedule */
                // check one more time
                if ($schedule->isAlive() !== true) {
                    $schedule->markAsDisappeared(sprintf('Host "%s" has not been available for a while now to update the status of this task and the task is not reporting back by itself', $schedule->getHost()));
                    $schedule->save();
                }
            }
        }

        // clean up "running"(!?) tasks that have never been seen (for whatever reason) and have been scheduled before maxAge
        // by robinfritze. @see https://github.com/AOEpeople/Aoe_Scheduler/issues/40#issuecomment-67749476
        $schedules = Mage::getModel('cron/schedule')->getCollection() /* @var $schedules Mage_Cron_Model_Resource_Schedule_Collection */
            ->addFieldToFilter('status', Aoe_Scheduler_Model_Schedule::STATUS_RUNNING)
            ->addFieldToFilter('last_seen', array('null' => true))
            ->addFieldToFilter('host', array('null' => true))
            ->addFieldToFilter('pid', array('null' => true))
            ->addFieldToFilter('scheduled_at', array('lt' => strftime('%Y-%m-%d %H:%M:00', $maxAge)))
            ->load();

        foreach ($schedules->getIterator() as $schedule) { /* @var $schedule Aoe_Scheduler_Model_Schedule */
            $schedule->setLastSeen(strftime('%Y-%m-%d %H:%M:%S', time()));
            $schedule->markAsDisappeared(sprintf('Process "%s" (id: %s) cannot be found anymore', $schedule->getJobCode(), $schedule->getId()));
        }

    }
public function checkRunningJobs()
    {
        $maxJobRuntime = intval(Mage::getStoreConfig(self::XML_PATH_MAX_JOB_RUNTIME));

        if ($maxJobRuntime) {
            foreach ($this->getAllRunningSchedules(gethostname()) as $schedule) { /* @var $schedule Aoe_Scheduler_Model_Schedule */
                // checking if the job isn't running too long
                if ($schedule->isAlive()) {
                    if ($schedule->getDuration() > $maxJobRuntime * 60 && !$schedule->getKillRequest()) {
                        $schedule->requestKill(null, 'Kill requested because job exceeded the max job runtime of ' . $maxJobRuntime . ' minutes.');
                    }
                }
            }
        }

        // fallback (where process cannot be checked or if one of the servers disappeared)
        // if a task wasn't seen for some time it will be marked as error
        $markAsErrorAfter = intval(Mage::getStoreConfig(self::XML_PATH_MARK_AS_ERROR));
        $maxAge = time() - min($markAsErrorAfter, 5) * 60;
        if ($markAsErrorAfter) {
            $schedules = Mage::getModel('cron/schedule')->getCollection()/* @var $schedules Mage_Cron_Model_Resource_Schedule_Collection */
            ->addFieldToFilter('status', Aoe_Scheduler_Model_Schedule::STATUS_RUNNING)
                ->addFieldToFilter('last_seen', array('lt' => strftime('%Y-%m-%d %H:%M:00', $maxAge)))
                ->load();

            foreach ($schedules as $schedule) { /* @var $schedule Aoe_Scheduler_Model_Schedule */
                // check one more time
                if ($schedule->isAlive() !== true) {
                    $schedule->markAsDisappeared(sprintf('Host "%s" has not been available for a while now to update the status of this task and the task is not reporting back by itself', $schedule->getHost()));
                    $schedule->save();
                }
            }
        }

        // clean up "running"(!?) tasks that have never been seen (for whatever reason) and have been scheduled before maxAge
        // by robinfritze. @see https://github.com/AOEpeople/Aoe_Scheduler/issues/40#issuecomment-67749476
        $schedules = Mage::getModel('cron/schedule')->getCollection() /* @var $schedules Mage_Cron_Model_Resource_Schedule_Collection */
            ->addFieldToFilter('status', Aoe_Scheduler_Model_Schedule::STATUS_RUNNING)
            ->addFieldToFilter('last_seen', array('null' => true))
            ->addFieldToFilter('host', array('null' => true))
            ->addFieldToFilter('pid', array('null' => true))
            ->addFieldToFilter('scheduled_at', array('lt' => strftime('%Y-%m-%d %H:%M:00', $maxAge)))
            ->load();

        foreach ($schedules->getIterator() as $schedule) { /* @var $schedule Aoe_Scheduler_Model_Schedule */
            $schedule->setLastSeen(strftime('%Y-%m-%d %H:%M:%S', time()));
            $schedule->markAsDisappeared(sprintf('Process "%s" (id: %s) cannot be found anymore', $schedule->getJobCode(), $schedule->getId()));
        }

    }
public function checkRunningJobs ( ) { $ maxJobRuntime = intval ( Mage :: getStoreConfig ( self :: XML_PATH_MAX_JOB_RUNTIME ) ) ; if ( $ maxJobRuntime ) { foreach ( $ this -> getAllRunningSchedules ( gethostname ( ) ) as $ schedule ) { /* @var $schedule Aoe_Scheduler_Model_Schedule */ // checking if the job isn't running too long if ( $ schedule -> isAlive ( ) ) { if ( $ schedule -> getDuration ( ) > $ maxJobRuntime * 60 && ! $ schedule -> getKillRequest ( ) ) { $ schedule -> requestKill ( null , 'Kill requested because job exceeded the max job runtime of ' . $ maxJobRuntime . ' minutes.' ) ; } } } } // fallback (where process cannot be checked or if one of the servers disappeared) // if a task wasn't seen for some time it will be marked as error $ markAsErrorAfter = intval ( Mage :: getStoreConfig ( self :: XML_PATH_MARK_AS_ERROR ) ) ; $ maxAge = time ( ) - min ( $ markAsErrorAfter , 5 ) * 60 ; if ( $ markAsErrorAfter ) { $ schedules = Mage :: getModel ( 'cron/schedule' ) -> getCollection ( ) /* @var $schedules Mage_Cron_Model_Resource_Schedule_Collection */ -> addFieldToFilter ( 'status' , Aoe_Scheduler_Model_Schedule :: STATUS_RUNNING ) -> addFieldToFilter ( 'last_seen' , array ( 'lt' => strftime ( '%Y-%m-%d %H:%M:00' , $ maxAge ) ) ) -> load ( ) ; foreach ( $ schedules as $ schedule ) { /* @var $schedule Aoe_Scheduler_Model_Schedule */ // check one more time if ( $ schedule -> isAlive ( ) !== true ) { $ schedule -> markAsDisappeared ( sprintf ( 'Host "%s" has not been available for a while now to update the status of this task and the task is not reporting back by itself' , $ schedule -> getHost ( ) ) ) ; $ schedule -> save ( ) ; } } } // clean up "running"(!?) tasks that have never been seen (for whatever reason) and have been scheduled before maxAge // by robinfritze. @see https://github.com/AOEpeople/Aoe_Scheduler/issues/40#issuecomment-67749476 $ schedules = Mage :: getModel ( 'cron/schedule' ) -> getCollection ( ) /* @var $schedules Mage_Cron_Model_Resource_Schedule_Collection */ -> addFieldToFilter ( 'status' , Aoe_Scheduler_Model_Schedule :: STATUS_RUNNING ) -> addFieldToFilter ( 'last_seen' , array ( 'null' => true ) ) -> addFieldToFilter ( 'host' , array ( 'null' => true ) ) -> addFieldToFilter ( 'pid' , array ( 'null' => true ) ) -> addFieldToFilter ( 'scheduled_at' , array ( 'lt' => strftime ( '%Y-%m-%d %H:%M:00' , $ maxAge ) ) ) -> load ( ) ; foreach ( $ schedules -> getIterator ( ) as $ schedule ) { /* @var $schedule Aoe_Scheduler_Model_Schedule */ $ schedule -> setLastSeen ( strftime ( '%Y-%m-%d %H:%M:%S' , time ( ) ) ) ; $ schedule -> markAsDisappeared ( sprintf ( 'Process "%s" (id: %s) cannot be found anymore' , $ schedule -> getJobCode ( ) , $ schedule -> getId ( ) ) ) ; } }
Check running jobs

@return void
Check running jobs