21

When running:

/usr/bin/php /var/www/magento2/bin/magento cron:run | grep -v "Ran jobs by schedule" >> /var/www/magento2/var/log/magento.cron.log

I get:

[Exception]                                                                  
  Notice: Undefined index: jobs in /home/ubuntu/repo/project/vendor/magento/
               module-cron/Model/Config/Converter/Db.php on line 39  
4
  • What does cron log says? Nov 11, 2016 at 13:52
  • There is an error in update.log: setup-cron.ERROR: Database 'my-db' does not exist or specified database server user does not have privileges to access this database.
    – tread
    Nov 14, 2016 at 6:03
  • So issue was that the data migration tool added cron entries at the wrong level: so did delete from core_config_data where path like 'crontab/jobs%'; community.magento.com/t5/Technical-Issues/…
    – tread
    Nov 14, 2016 at 6:28
  • Fixed the first issue but now running php /var/www/shootingstuff/update/cron.php gives PHP Warning: require_once(/dir/update/vendor/autoload.php): failed to open stream: No such file or directory in /dir/update/app/bootstrap.php on line 15 PHP Fatal error: require_once(): Failed opening required '/dir/update/vendor/autoload.php' (include_path='.:/usr/share/php') in /dir/update/app/bootstrap.php on line 15
    – tread
    Nov 14, 2016 at 6:34

5 Answers 5

50

In my case it was caused by some cron jobs migrated from Magento 1, in core_config_data. Magento 2 expects the format to be crontab/{groupname}/jobs/{code}, while the imported ones miss the group name (i.e. default). If that is your case you might want to delete the wrong entries in core_config_data, or update them to map the new cron jobs.

5
  • 4
    You might need to remove all crontab entries from core_config_data table and then run php bin/magento setup:upgrade.
    – Ndianabasi
    Jan 24, 2019 at 12:03
  • 1
    bin/magento ca:fl config was enough for me Aug 23, 2019 at 18:39
  • You're right! It's really there in core_config_data since this site that I'm working was migrated before from M1 to M2.1, Thanks again! Nov 12, 2019 at 3:04
  • 11
    Deleted 202 entries :) DELETE FROM core_config_data WHERE path LIKE 'crontab/%' AND path NOT LIKE 'crontab/default%' AND config_id > 0 I needed last part AND config_id > 0 because of safe mode. Dec 30, 2019 at 1:17
  • 1
    Thanks @DamodarBashyal for sharing query. Feb 20, 2020 at 11:03
7

I have the same error. This is the error when migration from Magento 1 to Magento 2. So I fixed it by remove all rows have "path" start by "crobtab" in table "core_config_data".

Then run this: php bin/magento setup:upgrade

And error fixed. Magento 2 will generate all cronjobs again.

1
  • thanks it worked for me. Nov 13, 2019 at 11:28
4

As rcason said: this issue is due to migration from Magento 1 to Magento 2. After removing from "core _config_data" all the values that starts with crontab/default... (under Config Path) the problem is solved, and M2 cron jobs now run with no issue.

1

Looks like you have the wrong format of cron configuration in database. Try cleanup cron_schedule table and try run cron again.

Also please check cron setting in system configuration.

1
  • 1
    There is nothing in cron_schedule
    – tread
    Nov 14, 2016 at 5:59
1

Please test in dev environment first!

Always backup your database before trying out new stuff!

The error I stumbled upon was:

Exception #0 (Exception): Warning: Undefined array key "jobs" in ./vendor/magento/module-cron/Model/Config/Converter/Db.php on line 39

I had to combine from answers and comments, so the SQL that worked for me was:

truncate cron_schedule;
DELETE FROM core_config_data WHERE path LIKE 'crontab/%';

then

php bin/magento setup:upgrade
php bin/magento setup:di:compile
php bin/magento cache:clean

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.