Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
If you run `drush crun` also disabled cron jobs are executed. (If you execute cron from backend 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'));
}
}
Comment | File | Size | Author |
---|---|---|---|
#3 | do-not-run-disabled-job-2871704.patch | 484 bytes | frantisekivanko |
|
Issue fork ultimate_cron-2871704
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
frantisekivanko CreditAttribution: frantisekivanko at WONDROUS commentedComment #3
frantisekivanko CreditAttribution: frantisekivanko at WONDROUS commentedComment #4
frantisekivanko CreditAttribution: frantisekivanko at WONDROUS commentedComment #5
c.nish2k3 CreditAttribution: c.nish2k3 as a volunteer 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 CreditAttribution: 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 crun
and disabled jobs executes as well.Guess it's time to port Elysia cron.
Comment #10
jefuri CreditAttribution: jefuri as a volunteer and at Synetic 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 CreditAttribution: wouters_f commentedThis is still happening so it seems.
Comment #12
jantoine CreditAttribution: jantoine as a volunteer 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 CreditAttribution: wesleymusgrove commented?
Comment #14
wesleymusgrove CreditAttribution: 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_cron
hook from getting executed?Why does this Ultimate Cron documentation say NOT to use
drush cron
and instead usedrush cron-run
?When I tried using
drush cron-run
it dumps out message that says:When I run
drush core:cron
I 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
isScheduled
function?See ultimate_cron\src\Entity\CronJob.php
Comment #15
wesleymusgrove CreditAttribution: 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`.