0

When running the following command, about 20 of the same record gets created in the database.

php bin/magento cron:run 

I think it's also making my plugins run the same amount of times as the record exists.

Any ideas on what could be causing this?

This is the screeshot of my cron_schedule table

https://imgur.com/a/phOgn

  • 1
    Can you post a screenshot showing some of the records that get created, and the XML code used to create the cron job... – Dennis van Schaik Dec 4 '17 at 12:57
  • I agree, this is very unclear. What database table are you even talking about? – Niels Dec 4 '17 at 13:08
  • Updated the post with screenshot of the table – zcoyne Dec 4 '17 at 13:43
1

The records are not the same, the date in the scheduled_at column is different. It seems you have defined your cronjob to run every minute, so a record is made for every minute. you have probably set your cronjob like this:

<schedule>* * * * *</schedule>

Just change the first * to */5 or */15 to run it every 5 or 15 minutes, or to 0 to run every hour.

For more detailed info about setting up cronjobs: https://en.wikipedia.org/wiki/Cron

  • Thanks for your answer. I have not edited any files between it working normally, and it doing this however. Which files should I look into, because it happens for every cron job. – zcoyne Dec 5 '17 at 9:10
  • I thought it was a custom cron job, but the cron job you are referring to is a default Magento cron job. did you set up your cron to run every 5 minutes, or do you only run it via the CLI? I think that might be the problem. just set it up to run every 5 minutes and see if it keeps generating so much records. – Dennis van Schaik Dec 5 '17 at 19:38
  • I'm going to set it up to ring every night at 12, although in testing stages I am doing it via CLI. – zcoyne Dec 7 '17 at 14:50
  • You need to run it much more often, since stuff like sending out order confirmation e-mails is also done via the cron. so it is best to set it to run every 5 minutes. You can check devdocs.magento.com/guides/v2.0/config-guide/cli/… for a more detailed list of the actions that are being performed by the cron. – Dennis van Schaik Dec 7 '17 at 15:09
  • I mean my plugin. I thought the Magento cron jobs are already set up? – zcoyne Dec 13 '17 at 10:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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