# How not to run the scheduled workflow if the previous one is still running?

**URL:** <https://discuss.circleci.com/t/how-not-to-run-the-scheduled-workflow-if-the-previous-one-is-still-running/45938>\
**Category:** Build Environment\
**Created:** [October 29, 2022, 8:03am UTC](https://discuss.circleci.com/t/how-not-to-run-the-scheduled-workflow-if-the-previous-one-is-still-running/45938 "2022-10-29T08:03:09Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![perekrestov](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/perekrestov/32/31469_2.png) [@perekrestov](https://discuss.circleci.com/u/perekrestov)\
**Post date:** [October 29, 2022, 8:03am UTC](https://discuss.circleci.com/t/how-not-to-run-the-scheduled-workflow-if-the-previous-one-is-still-running/45938/1 "2022-10-29T08:03:09Z")

</div>

I have a workflow that is scheduled by trigger (every 15 min).  
In most cases, the execution time takes about 2 minutes.  
But in rare cases, the execution time can be more than 15 min (it is the correct behavior). And this overlapping is not good, there can be conflicts.

How can I skip the workflow if the previous one is still running?

---

<div class="post-metadata">

**Author:** ![rit1010](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/rit1010/32/34738_2.png) [@rit1010](https://discuss.circleci.com/u/rit1010)\
**Post date:** [October 29, 2022, 2:47pm UTC](https://discuss.circleci.com/t/how-not-to-run-the-scheduled-workflow-if-the-previous-one-is-still-running/45938/2 "2022-10-29T14:47:09Z")

</div>

Circleci does not have such a feature within its core scripting, but there are a number of ORBs published by third parties that try to provide some form of lock, queuing API using external systems.

The one that was provided as an answer by a Circleci staff member is this one

> **[CircleCI Developer Hub - eddiewebb/queue](https://circleci.com/developer/orbs/orb/eddiewebb/queue)**
>
> Allows jobs or entire workflows to be queued to ensure they run in serial.  
> This is ideal for deployments or other activities that must not run concurrently.
> May optionaly consider branch-level isolation if unique branches should run concurrently....

I’ve not tried any of these solutions, for a simple requirement on one of the projects I used an external key-value store and a few curl based rest API calls that allowed me to set, check and delete a value that was available across workflows and jobs.

---

<div class="post-metadata">

**Author:** ![perekrestov](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/perekrestov/32/31469_2.png) [@perekrestov](https://discuss.circleci.com/u/perekrestov)\
**Post date:** [October 31, 2022, 1:53pm UTC](https://discuss.circleci.com/t/how-not-to-run-the-scheduled-workflow-if-the-previous-one-is-still-running/45938/3 "2022-10-31T13:53:04Z")

</div>

Thanks, @rit1010 !

> an external key-value store

I thought about too.

But using a ready-made function is much more convenient.  
The `eddiewebb/queue` orb looks exactly like what I need!

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/circleci/original/3X/5/1/511608acda8e85906e15909b57bd0a46c1dbe291.png) [@system](https://discuss.circleci.com/u/system)\
**Post date:** [November 10, 2022, 1:53pm UTC](https://discuss.circleci.com/t/how-not-to-run-the-scheduled-workflow-if-the-previous-one-is-still-running/45938/4 "2022-11-10T13:53:35Z")

</div>

Closed on November 10, 2022, 1:53pm UTC

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.
