It appears that cron jobs in Magento 2 are limited by their settings defined in the cron group they belong to. I'm not sure if this is a bug or a feature.
Alex Gusev already points this out in his answer, but to clarify it a bit more: There are 2 cron groups by default in Magento 2:
index. These are defined in
Magento_Cron/etc/cron_groups.xml. For example:
These cron group determine the default / global values of every cron job. I'm not sure how it works but according to my own tests you cannot set a cron to run more often per hour than determined in the
schedule_generate_every-setting. So for example, if you have something like this:
<job name="custom_module" instance="Custom\Module\Cron\DoSomething" method="execute">
<schedule>*/1 * * * *</schedule>
Even though you might expect that this cronjob is scheduled every minute, it's global settings limit it to a minimum timeframe of 15 minutes.
To solve this, you can either:
- Edit the setting in the system configuration (Advanced → System → Cron), or:
- Override the global default in your module by adding a
cron_groups.xml-file of your own (assuming that the client did not already tinker with the configuration settings):
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Cron:etc/cron_groups.xsd">
Bug? Feature? Misleading configuration setting? I'm not sure how to call this. You could argue that it's a good thing that you have a global scope that can limit 100+ modules to try to run a cron every minute. On the other hand: If I'm a developer who knows what he's doing, there might be good reasons to run every minute.
If running every minute is mandatory it might also be an idea to add a whole new cron group for your configuration (don't pollute the
index-cron group with non-indexing cron jobs). But that's a matter of architecture and I'll leave that up to you.