# RemoveIfExists does not remove jobs in Scheduled state

**URL:** <https://discuss.hangfire.io/t/removeifexists-does-not-remove-jobs-in-scheduled-state/7876>\
**Category:** bug?\
**Tags:** recurring\
**Created:** [October 17, 2020, 3:11pm UTC](https://discuss.hangfire.io/t/removeifexists-does-not-remove-jobs-in-scheduled-state/7876 "2020-10-17T15:11:41Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![flipdoubt](https://dub1.discourse-cdn.com/flex017/user_avatar/discuss.hangfire.io/flipdoubt/32/1939_2.png) [@flipdoubt](https://discuss.hangfire.io/u/flipdoubt)\
**Post date:** [October 17, 2020, 3:11pm UTC](https://discuss.hangfire.io/t/removeifexists-does-not-remove-jobs-in-scheduled-state/7876/1 "2020-10-17T15:11:41Z")

</div>

We use `IRecurringJobManager.AddOrUpdate` to successfully schedule a job. In our test scenario, running the job throws `NotImplementedException` and keeps the job in `Scheduled` state, as seen in the `hangfire.job` table (using MSSQL storage). After “noticing” the error, we stop the job using `IRecurringJobManager.RemoveIfExists`, but the scheduled job remains and gets triggered by `Hangfire.AutomaticRetryAttribute`. This seems like a bug to me in that the scheduled jobs should be removed when I remove the schedule.

How can we trigger the removal of a scheduled job when removing the recurring job? We do not explicitly add or remove the `AutomaticRetryAttribute` but still consider this an illogical result after the recurring job has been removed.

---

<div class="post-metadata">

**Author:** ![flipdoubt](https://dub1.discourse-cdn.com/flex017/user_avatar/discuss.hangfire.io/flipdoubt/32/1939_2.png) [@flipdoubt](https://discuss.hangfire.io/u/flipdoubt)\
**Post date:** [November 19, 2020, 3:35pm UTC](https://discuss.hangfire.io/t/removeifexists-does-not-remove-jobs-in-scheduled-state/7876/2 "2020-11-19T15:35:30Z")

</div>

Any suggestions on how to remove retry events when removing a scheduled job? Typically, an error occurs and we use RemoveIfExists assuming this will prevent the job from running until we correct the error.

---

<div class="post-metadata">

**Author:** ![MohamedAliTera](https://dub1.discourse-cdn.com/flex017/user_avatar/discuss.hangfire.io/mohamedalitera/32/3965_2.png) [@MohamedAliTera](https://discuss.hangfire.io/u/MohamedAliTera)\
**Post date:** [April 10, 2025, 10:04am UTC](https://discuss.hangfire.io/t/removeifexists-does-not-remove-jobs-in-scheduled-state/7876/3 "2025-04-10T10:04:36Z")

</div>

Did you find a solution for this?
