# Disable scheduler when retrieving next\_run

**URL:** <https://forum.ansible.com/t/disable-scheduler-when-retrieving-next-run/35950>\
**Category:** AWX Project\
**Tags:** awx\
**Created:** [November 2, 2021, 3:14pm UTC](https://forum.ansible.com/t/disable-scheduler-when-retrieving-next-run/35950 "2021-11-02T15:14:11Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Gary\_Thomson](https://avatars.discourse-cdn.com/v4/letter/g/2bfe46/32.png) [@Gary\_Thomson](https://forum.ansible.com/u/Gary_Thomson)\
**Post date:** [November 2, 2021, 3:14pm UTC](https://forum.ansible.com/t/disable-scheduler-when-retrieving-next-run/35950/1 "2021-11-02T15:14:11Z")

</div>

Hi all,

I have a python script which requests the awx schedules via the REST API, the script loops for each schedule, enables the schedule, retrieves the schedule detail including next\_run then disables the schedule again. The next\_run value is unavailable via the API when the schedule is disabled (hence the enable).  
There is a chance that my script will enable a schedule which is due to run during that enabled period thus the scheduler may start the job (patch and reboot the server), is there a way to disable the scheduler whilst my script is retrieving the next\_run datetime please? Or and alternative method to retrieve the next\_run without enabling the schedule.

Thanks very much for your help.  
Gary

---

<div class="post-metadata">

**Author:** ![Gary\_Thomson](https://avatars.discourse-cdn.com/v4/letter/g/2bfe46/32.png) [@Gary\_Thomson](https://forum.ansible.com/u/Gary_Thomson)\
**Post date:** [November 2, 2021, 5:44pm UTC](https://forum.ansible.com/t/disable-scheduler-when-retrieving-next-run/35950/2 "2021-11-02T17:44:33Z")

</div>

Hi,  
I should have read the schedules.md more thoroughly, there’s a /schedules/preview/ endpoint that gives me what I need

preview\_payload: {“rrule”: “DTSTART;TZID=Europe/Brussels:20211025T100000 RRULE:FREQ=WEEKLY;INTERVAL=4;BYDAY=MO”}

response: {‘local’: [‘ **2021-11-22T10:00:00+01:00** ’, ‘2021-12-20T10:00:00+01:00’, ‘2022-01-17T10:00:00+01:00’, ‘2022-02-14T10:00:00+01:00’, ‘2022-03-14T10:00:00+01:00’, ‘2022-04-11T10:00:00+02:00’, ‘2022-05-09T10:00:00+02:00’, ‘2022-06-06T10:00:00+02:00’, ‘2022-07-04T10:00:00+02:00’, ‘2022-08-01T10:00:00+02:00’], ‘utc’: [‘2021-11-22T09:00:00Z’, ‘2021-12-20T09:00:00Z’, ‘2022-01-17T09:00:00Z’, ‘2022-02-14T09:00:00Z’, ‘2022-03-14T09:00:00Z’, ‘2022-04-11T08:00:00Z’, ‘2022-05-09T08:00:00Z’, ‘2022-06-06T08:00:00Z’, ‘2022-07-04T08:00:00Z’, ‘2022-08-01T08:00:00Z’]}

---

<div class="post-metadata">

**Author:** ![AlanCoding](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/alancoding/32/301_2.png) [@AlanCoding](https://forum.ansible.com/u/AlanCoding)\
**Post date:** [December 6, 2021, 7:18pm UTC](https://forum.ansible.com/t/disable-scheduler-when-retrieving-next-run/35950/3 "2021-12-06T19:18:43Z")

</div>

At a time, I remember that we had some performance problems updating the next\_run field. For various reasons, users would end up with a lot of short-cycle schedules that are normally disabled. Updating the next\_run would result in a lot of updates, independent of the actual workload of the system.

The preview endpoint is a good alternative for the use case you mention.

Alan  
github: AlanCoding
