Disable scheduler when retrieving next_run

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

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’]}

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