# Kill job allocation when workflow ends

**URL:** <https://aiida.discourse.group/t/kill-job-allocation-when-workflow-ends/685>\
**Category:** Developer\
**Created:** [October 9, 2025, 6:18pm UTC](https://aiida.discourse.group/t/kill-job-allocation-when-workflow-ends/685 "2025-10-09T18:18:55Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![nkeilbart](https://yyz2.discourse-cdn.com/free1/user_avatar/aiida.discourse.group/nkeilbart/32/40_2.png) [@nkeilbart](https://aiida.discourse.group/u/nkeilbart)\
**Post date:** [October 9, 2025, 6:18pm UTC](https://aiida.discourse.group/t/kill-job-allocation-when-workflow-ends/685/1 "2025-10-09T18:18:55Z")

</div>

I’ve been working on a persistent scheduler plugin which creates an allocation that it can proxy into and submit more jobs. I have it all working but have now come to the part where I need to kill the allocation if the jobs finish before hitting the maximum walltime allocated. Is there a function in the scheduler section or other parts of aiida-core that would get triggered after a job is finished to see if there are more jobs to be submitted in the workchain?

---

<div class="post-metadata">

**Author:** ![giovannipizzi](https://yyz2.discourse-cdn.com/free1/user_avatar/aiida.discourse.group/giovannipizzi/32/17_2.png) [@giovannipizzi](https://aiida.discourse.group/u/giovannipizzi)\
**Post date:** [October 10, 2025, 6:22pm UTC](https://aiida.discourse.group/t/kill-job-allocation-when-workflow-ends/685/2 "2025-10-10T18:22:48Z")

</div>

Hi,

just to confirm, do you want to terminate the job allocation from AiiDA when no more jobs exist? This might be possible but tricky. Some other similar solutions, e.g. hyperqueue ([HyperQueue](https://it4innovations.github.io/hyperqueue/stable/)), just kill the job on the scheduler if no more jobs are submitted for, say, 5 mins.

BTW, did you already check hyper queue? Maybe it solves your needs, and we have a plugin for it ([GitHub - aiidateam/aiida-hyperqueue: AiiDA plugin for the HyperQueue metascheduler.](https://github.com/aiidateam/aiida-hyperqueue))

---

<div class="post-metadata">

**Author:** ![nkeilbart](https://yyz2.discourse-cdn.com/free1/user_avatar/aiida.discourse.group/nkeilbart/32/40_2.png) [@nkeilbart](https://aiida.discourse.group/u/nkeilbart)\
**Post date:** [October 13, 2025, 3:12pm UTC](https://aiida.discourse.group/t/kill-job-allocation-when-workflow-ends/685/3 "2025-10-13T15:12:10Z")

</div>

Thank you for the feedback. Yes I’ve had HyperQueue suggested by several people. I’ll take a look to see how they implement this feature. I still do need to develop the Flux plugin as that is what we are using at LLNL.

---

<div class="post-metadata">

**Author:** ![nkeilbart](https://yyz2.discourse-cdn.com/free1/user_avatar/aiida.discourse.group/nkeilbart/32/40_2.png) [@nkeilbart](https://aiida.discourse.group/u/nkeilbart)\
**Post date:** [October 13, 2025, 11:19pm UTC](https://aiida.discourse.group/t/kill-job-allocation-when-workflow-ends/685/4 "2025-10-13T23:19:08Z")

</div>

@giovannipizzi Could you point me to the example you were mentioning. I went through the HQ plugin but didn’t see a functionality that kills the job allocation.

---

<div class="post-metadata">

**Author:** ![giovannipizzi](https://yyz2.discourse-cdn.com/free1/user_avatar/aiida.discourse.group/giovannipizzi/32/17_2.png) [@giovannipizzi](https://aiida.discourse.group/u/giovannipizzi)\
**Post date:** [October 14, 2025, 9:11pm UTC](https://aiida.discourse.group/t/kill-job-allocation-when-workflow-ends/685/5 "2025-10-14T21:11:47Z")

</div>

Sorry, what I meant is that hyperqueue takes care of this. If you stop submitting, so eventually a worker on the scheduler has no jobs to poll and processs, after a configurable time (default: 5 minutes) the worker will terminate to avoid wasting computational nodes. This is the [idle timeout in hyperqueue]( [Workers - HyperQueue](https://it4innovations.github.io/hyperqueue/stable/deployment/worker/#idle-timeout) ). I think it’s a good idea to try to push this outside of AiiDA and let the “meta” scheduler take care of it as it will be more robust. E.g.: it can work by reusing workers also between independent workflows (even from independent AiiDA profiles/databases, if wanted), and if will “guarantee” that the jobs stop after X minutes independent of AiiDA (e.g., say there is a connection issue or you rebooted the AiiDA machine - this might prevent AiiDA from promptly terminating your allocations)

---

<div class="post-metadata">

**Author:** ![nkeilbart](https://yyz2.discourse-cdn.com/free1/user_avatar/aiida.discourse.group/nkeilbart/32/40_2.png) [@nkeilbart](https://aiida.discourse.group/u/nkeilbart)\
**Post date:** [October 15, 2025, 5:08pm UTC](https://aiida.discourse.group/t/kill-job-allocation-when-workflow-ends/685/6 "2025-10-15T17:08:36Z")

</div>

Yeah those points make a lot of sense. I ended up putting a simple bash command to kill the allocation if there were no jobs after so many minutes. Thanks for the suggestions.
