cancel
Showing results for 
Search instead for 
Did you mean: 

Error when running cron job: Undefined index: jobs

Error when running cron job: Undefined index: jobs

I'm setting up the cron job on my web server for my new Magento 2.0 website however it's not working.

 

Here is the script it's scheduled to run (with the absolute path changed to **magento_dir**):

* * * * * web50 /usr/bin/php -c /etc/php.ini **magento_dir**/bin/magento cron:run | grep -v "Ran jobs by schedule" >> **magento_dir**/var/log/magento.cron.log

It created a blank log file and that's all.

 

I tried to run the script manually to see what would happen and I get the following error:

 [ErrorException]
 Undefined index: jobs

Any ideas why this is happening?

2 REPLIES

Re: Error when running cron job: Undefined index: jobs

This happened to me after running the data migration tool. It added crons at the wrong level.

 

A quick fix was to change:

 

protected function \Magento\Cron\Model\Config\Converter\Db::_extractParams(array $cronTab){
    $result = [];
    foreach ($cronTab as $groupName => $groupConfig) {
        $jobs = isset($groupConfig['jobs']) ? $groupConfig['jobs'] : $groupConfig;
        foreach ($jobs as $jobName => $value) {
            $result[$groupName][$jobName] = $value;
            if (isset($value['schedule']) && is_array($value['schedule'])) {
               $this->_processConfigParam($value, $jobName, $result[$groupName]);
                $this->_processScheduleParam($value, $jobName, $result[$groupName]);
            }
            $this->_processRunModel($value, $jobName, $result[$groupName]);
        }
    }
    return $result;
}


 

Otherwise I'm planing to write my own import routine and not import settings/attributes

 

Re: Error when running cron job: Undefined index: jobs

OR just "TRUNCATE cron_schedule" and "delete from core_config_data where path like 'crontab/jobs%';"