If you run drush cron, disabled cron jobs are also executed. (If you execute cron from the admin interface only enabled cron jobs will be executed.)
ultimate_cron.drush.inc // drush_ultimate_cron_cron_run
// Run all jobs.
$jobs = CronJob::loadMultiple();
/** @var CronJob $job */
foreach($jobs as $job) {
if ($force || $job->isScheduled()) {
$job->run(t('Launched by drush'));
}
}
Should be something like that.
// Run all jobs.
$jobs = CronJob::loadMultiple();
/** @var CronJob $job */
foreach($jobs as $job) {
if ($force || ($job->status() === TRUE && $job->isScheduled())) {
$job->run(t('Launched by drush'));
}
}
Comments
Comment #2
frantisekivanko commentedComment #3
frantisekivanko commentedComment #4
frantisekivanko commentedComment #5
c.nish2k3 commentedComment #6
berdirNote that it's easy to avoid this by using the standard core drush command to run cron: drush core-cron. This works fine, uses the cron service and respects the status.
I'm not sure if we shouldn't just remove this method completely and just keep the option to run one specific cron job.
It's also missing other things like processing queues (unless queues are exposes as cron jobs), setting the last run status and so on.
Comment #7
maosmurf commentedThank you for the patch!
The ultimate_cron setup with exposed queues works great for us.
Wouldn't this make the whole module more or less useless?
We love ultimate_cron for 2 reasons:
* multiple, independent tasks per module (not limited to hook_cron)
* flexible configuration of schedules
Comment #8
berdirNo, it does not, the module replaces the service that does the cron processing, it works just fine if you use drush core-cron.
Comment #9
kala4ekWe launching cron via
drush crunand disabled jobs executes as well.Guess it's time to port Elysia cron.
Comment #10
jefuri commented@Berdir wouldn't relying on the core-cron make custom options not available to use that cron-run does support? Like threads and stuff.
Comment #11
wouters_f commentedThis is still happening so it seems.
Comment #12
jantoine commentedI'm running into a related problem that I found an issue for here: #3163408: Ultimate Cron Timezone issue as cron executed both in IST and UTC. It's not the same issue, but it's an issue with @Berdir's workaround suggestion, to use core's cron, in #6. The issue is that core's cron is running processes for both the local timezone and UTC when executed via drush. Once this issue is resolved, perhaps @Berdir's suggestion would work, but as it stands, this is not a workable solution for me.
Comment #13
wesleymusgrove commented?
Comment #14
wesleymusgrove commentedI have disabled a cron job using the admin interface (/admin/config/system/cron/jobs) that was originally running every 15 minutes, however it is still being executed months after I disabled it. All cron tasks are being executed by an Acquia scheduled job that is running
drush cron. I thought disabling a specific custom module's cron task in the admin interface would prevent itshook_cronhook from getting executed?Why does this Ultimate Cron documentation say NOT to use
drush cronand instead usedrush cron-run?When I tried using
drush cron-runit dumps out message that says:When I run
drush core:cronI can hit breakpoints inside the hook_cron function for the job that I have disabled in the admin interface. I havedrush cr'd. Why is this hook still being hit if the job is disabled?Isn't the status enabled/disabled check proposed by this patch already being done in the
isScheduledfunction?See ultimate_cron\src\Entity\CronJob.php
Comment #15
wesleymusgrove commentedI think my issue is that my custom hook_cron implementation processed a Drupal queue. It _wasn't_ executing a disabled cron job. However after it finished running all the enabled cron jobs, it then started processing all the Drupal queues. So it appeared that my cron hook was running, but really it was this code doing it in ultimate_cron\src\UltimateCron.php
I didn't realize it was processing Drupal queues by default. Looks like I need to override the default queue processing for my custom queue that I'm trying to disable here: /admin/config/system/cron/settings
Comment #16
a.milkovskyThis issue is outdated, as only a single job can be passed to the drush command `cron-run`.
Comment #17
solideogloria commentedImprove issue summary formatting.
Comment #18
solideogloria commentedThis is true. From the code: