prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  Token and Session Expiration never run after the first time
  ### Please confirm the following
  
  - [X] I agree to follow this project's [code of conduct](https://docs.ansible.com/ansible/latest/community/code_of_conduct.html).
  - [X] I have checked the [current issues](https://github.com/ansible/awx/issues) for duplicates.
  - [X] I understand that AWX is open source software provided for free and that I might not receive a timely response.
  
  ### Bug Summary
  
  Looks like when we implemented token and session cleanup way back in https://github.com/ansible/awx/pull/3856
  
  We populated the recurrence rule incorrectly:
  
  https://github.com/ansible/awx/blob/8a06ffbe15c9f8e68b1da86e5ca7daf5ecfd6da4/awx/main/migrations/_create_system_jobs.py#L39
  
  This schedule will only ever run once due to `COUNT=1`.... we should omit that so that it will periodically run.
  
  ### AWX version
  
  latest
  
  ### Select the relevant components
  
  - [ ] UI
  - [X] API
  - [ ] Docs
  - [ ] Collection
  - [ ] CLI
  - [ ] Other
  
  ### Installation method
  
  minishift
  
  ### Modifications
  
  no
  
  ### Ansible version
  
  _No response_
  
  ### Operating system
  
  _No response_
  
  ### Web browser
  
  _No response_
  
  ### Steps to reproduce
  
  install awx
  
  ### Expected results
  
  periodic running of these management jobs
  
  ### Actual results
  
  the jobs only run once
  
  ### Additional information
  
  _No response_
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `awx/main/migrations/_create_system_jobs.py`
  Content:
  ```
  1 import logging
  2 
  3 from django.utils.timezone import now
  4 
  5 logger = logging.getLogger('awx.main.migrations')
  6 
  7 __all__ = ['create_collection_jt', 'create_clearsessions_jt', 'create_cleartokens_jt']
  8 
  9 '''
  10 These methods are called by migrations to create various system job templates
  11 
  12 Create default system job templates if not present. Create default schedules
  13 only if new system job templates were created (i.e. new database).
  14 '''
  15 
  16 
  17 def create_clearsessions_jt(apps, schema_editor):
  18 
  19     SystemJobTemplate = apps.get_model('main', 'SystemJobTemplate')
  20     Schedule = apps.get_model('main', 'Schedule')
  21     ContentType = apps.get_model('contenttypes', 'ContentType')
  22     sjt_ct = ContentType.objects.get_for_model(SystemJobTemplate)
  23     now_dt = now()
  24     schedule_time = now_dt.strftime('%Y%m%dT%H%M%SZ')
  25 
  26     sjt, created = SystemJobTemplate.objects.get_or_create(
  27         job_type='cleanup_sessions',
  28         defaults=dict(
  29             name='Cleanup Expired Sessions',
  30             description='Cleans out expired browser sessions',
  31             polymorphic_ctype=sjt_ct,
  32             created=now_dt,
  33             modified=now_dt,
  34         ),
  35     )
  36     if created:
  37         sched = Schedule(
  38             name='Cleanup Expired Sessions',
  39             rrule='DTSTART:%s RRULE:FREQ=WEEKLY;INTERVAL=1;COUNT=1' % schedule_time,
  40             description='Cleans out expired browser sessions',
  41             enabled=True,
  42             created=now_dt,
  43             modified=now_dt,
  44             extra_data={},
  45         )
  46         sched.unified_job_template = sjt
  47         sched.save()
  48 
  49 
  50 def create_cleartokens_jt(apps, schema_editor):
  51 
  52     SystemJobTemplate = apps.get_model('main', 'SystemJobTemplate')
  53     Schedule = apps.get_model('main', 'Schedule')
  54     ContentType = apps.get_model('contenttypes', 'ContentType')
  55     sjt_ct = ContentType.objects.get_for_model(SystemJobTemplate)
  56     now_dt = now()
  57     schedule_time = now_dt.strftime('%Y%m%dT%H%M%SZ')
  58 
  59     sjt, created = SystemJobTemplate.objects.get_or_create(
  60         job_type='cleanup_tokens',
  61         defaults=dict(
  62             name='Cleanup Expired OAuth 2 Tokens',
  63             description='Cleanup expired OAuth 2 access and refresh tokens',
  64             polymorphic_ctype=sjt_ct,
  65             created=now_dt,
  66             modified=now_dt,
  67         ),
  68     )
  69     if created:
  70         sched = Schedule(
  71             name='Cleanup Expired OAuth 2 Tokens',
  72             rrule='DTSTART:%s RRULE:FREQ=WEEKLY;INTERVAL=1;COUNT=1' % schedule_time,
  73             description='Removes expired OAuth 2 access and refresh tokens',
  74             enabled=True,
  75             created=now_dt,
  76             modified=now_dt,
  77             extra_data={},
  78         )
  79         sched.unified_job_template = sjt
  80         sched.save()
  81
  ```
  --- END FILES ---
  
  Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.
  
  Here is an example:
  
  ```diff
  diff --git a/examples/server_async.py b/examples/server_async.py
  --- a/examples/server_async.py
  +++ b/examples/server_async.py
  @@ -313,4 +313,4 @@
   
   
   if __name__ == "__main__":
  -    asyncio.run(run_async_server("."), debug=True)
  +    asyncio.run(run_async_server(), debug=True)
  diff --git a/examples/server_sync.py b/examples/server_sync.py
  --- a/examples/server_sync.py
  +++ b/examples/server_sync.py
  @@ -313,5 +313,5 @@
   
   
   if __name__ == "__main__":
  -    server = run_sync_server(".")
  +    server = run_sync_server()
       server.shutdown()
  
  ```
  
golden_diff: diff --git a/awx/main/migrations/_create_system_jobs.py b/awx/main/migrations/_create_system_jobs.py
  --- a/awx/main/migrations/_create_system_jobs.py
  +++ b/awx/main/migrations/_create_system_jobs.py
  @@ -36,7 +36,7 @@
       if created:
           sched = Schedule(
               name='Cleanup Expired Sessions',
  -            rrule='DTSTART:%s RRULE:FREQ=WEEKLY;INTERVAL=1;COUNT=1' % schedule_time,
  +            rrule='DTSTART:%s RRULE:FREQ=WEEKLY;INTERVAL=1' % schedule_time,
               description='Cleans out expired browser sessions',
               enabled=True,
               created=now_dt,
  @@ -69,7 +69,7 @@
       if created:
           sched = Schedule(
               name='Cleanup Expired OAuth 2 Tokens',
  -            rrule='DTSTART:%s RRULE:FREQ=WEEKLY;INTERVAL=1;COUNT=1' % schedule_time,
  +            rrule='DTSTART:%s RRULE:FREQ=WEEKLY;INTERVAL=1' % schedule_time,
               description='Removes expired OAuth 2 access and refresh tokens',
               enabled=True,
               created=now_dt,
  
verification_info: {"golden_diff": "diff --git a/awx/main/migrations/_create_system_jobs.py b/awx/main/migrations/_create_system_jobs.py\n--- a/awx/main/migrations/_create_system_jobs.py\n+++ b/awx/main/migrations/_create_system_jobs.py\n@@ -36,7 +36,7 @@\n     if created:\n         sched = Schedule(\n             name='Cleanup Expired Sessions',\n-            rrule='DTSTART:%s RRULE:FREQ=WEEKLY;INTERVAL=1;COUNT=1' % schedule_time,\n+            rrule='DTSTART:%s RRULE:FREQ=WEEKLY;INTERVAL=1' % schedule_time,\n             description='Cleans out expired browser sessions',\n             enabled=True,\n             created=now_dt,\n@@ -69,7 +69,7 @@\n     if created:\n         sched = Schedule(\n             name='Cleanup Expired OAuth 2 Tokens',\n-            rrule='DTSTART:%s RRULE:FREQ=WEEKLY;INTERVAL=1;COUNT=1' % schedule_time,\n+            rrule='DTSTART:%s RRULE:FREQ=WEEKLY;INTERVAL=1' % schedule_time,\n             description='Removes expired OAuth 2 access and refresh tokens',\n             enabled=True,\n             created=now_dt,\n", "issue": "Token and Session Expiration never run after the first time\n### Please confirm the following\n\n- [X] I agree to follow this project's [code of conduct](https://docs.ansible.com/ansible/latest/community/code_of_conduct.html).\n- [X] I have checked the [current issues](https://github.com/ansible/awx/issues) for duplicates.\n- [X] I understand that AWX is open source software provided for free and that I might not receive a timely response.\n\n### Bug Summary\n\nLooks like when we implemented token and session cleanup way back in https://github.com/ansible/awx/pull/3856\r\n\r\nWe populated the recurrence rule incorrectly:\r\n\r\nhttps://github.com/ansible/awx/blob/8a06ffbe15c9f8e68b1da86e5ca7daf5ecfd6da4/awx/main/migrations/_create_system_jobs.py#L39\r\n\r\nThis schedule will only ever run once due to `COUNT=1`.... we should omit that so that it will periodically run.\n\n### AWX version\n\nlatest\n\n### Select the relevant components\n\n- [ ] UI\n- [X] API\n- [ ] Docs\n- [ ] Collection\n- [ ] CLI\n- [ ] Other\n\n### Installation method\n\nminishift\n\n### Modifications\n\nno\n\n### Ansible version\n\n_No response_\n\n### Operating system\n\n_No response_\n\n### Web browser\n\n_No response_\n\n### Steps to reproduce\n\ninstall awx\n\n### Expected results\n\nperiodic running of these management jobs\n\n### Actual results\n\nthe jobs only run once\n\n### Additional information\n\n_No response_\n", "before_files": [{"content": "import logging\n\nfrom django.utils.timezone import now\n\nlogger = logging.getLogger('awx.main.migrations')\n\n__all__ = ['create_collection_jt', 'create_clearsessions_jt', 'create_cleartokens_jt']\n\n'''\nThese methods are called by migrations to create various system job templates\n\nCreate default system job templates if not present. Create default schedules\nonly if new system job templates were created (i.e. new database).\n'''\n\n\ndef create_clearsessions_jt(apps, schema_editor):\n\n    SystemJobTemplate = apps.get_model('main', 'SystemJobTemplate')\n    Schedule = apps.get_model('main', 'Schedule')\n    ContentType = apps.get_model('contenttypes', 'ContentType')\n    sjt_ct = ContentType.objects.get_for_model(SystemJobTemplate)\n    now_dt = now()\n    schedule_time = now_dt.strftime('%Y%m%dT%H%M%SZ')\n\n    sjt, created = SystemJobTemplate.objects.get_or_create(\n        job_type='cleanup_sessions',\n        defaults=dict(\n            name='Cleanup Expired Sessions',\n            description='Cleans out expired browser sessions',\n            polymorphic_ctype=sjt_ct,\n            created=now_dt,\n            modified=now_dt,\n        ),\n    )\n    if created:\n        sched = Schedule(\n            name='Cleanup Expired Sessions',\n            rrule='DTSTART:%s RRULE:FREQ=WEEKLY;INTERVAL=1;COUNT=1' % schedule_time,\n            description='Cleans out expired browser sessions',\n            enabled=True,\n            created=now_dt,\n            modified=now_dt,\n            extra_data={},\n        )\n        sched.unified_job_template = sjt\n        sched.save()\n\n\ndef create_cleartokens_jt(apps, schema_editor):\n\n    SystemJobTemplate = apps.get_model('main', 'SystemJobTemplate')\n    Schedule = apps.get_model('main', 'Schedule')\n    ContentType = apps.get_model('contenttypes', 'ContentType')\n    sjt_ct = ContentType.objects.get_for_model(SystemJobTemplate)\n    now_dt = now()\n    schedule_time = now_dt.strftime('%Y%m%dT%H%M%SZ')\n\n    sjt, created = SystemJobTemplate.objects.get_or_create(\n        job_type='cleanup_tokens',\n        defaults=dict(\n            name='Cleanup Expired OAuth 2 Tokens',\n            description='Cleanup expired OAuth 2 access and refresh tokens',\n            polymorphic_ctype=sjt_ct,\n            created=now_dt,\n            modified=now_dt,\n        ),\n    )\n    if created:\n        sched = Schedule(\n            name='Cleanup Expired OAuth 2 Tokens',\n            rrule='DTSTART:%s RRULE:FREQ=WEEKLY;INTERVAL=1;COUNT=1' % schedule_time,\n            description='Removes expired OAuth 2 access and refresh tokens',\n            enabled=True,\n            created=now_dt,\n            modified=now_dt,\n            extra_data={},\n        )\n        sched.unified_job_template = sjt\n        sched.save()\n", "path": "awx/main/migrations/_create_system_jobs.py"}], "after_files": [{"content": "import logging\n\nfrom django.utils.timezone import now\n\nlogger = logging.getLogger('awx.main.migrations')\n\n__all__ = ['create_collection_jt', 'create_clearsessions_jt', 'create_cleartokens_jt']\n\n'''\nThese methods are called by migrations to create various system job templates\n\nCreate default system job templates if not present. Create default schedules\nonly if new system job templates were created (i.e. new database).\n'''\n\n\ndef create_clearsessions_jt(apps, schema_editor):\n\n    SystemJobTemplate = apps.get_model('main', 'SystemJobTemplate')\n    Schedule = apps.get_model('main', 'Schedule')\n    ContentType = apps.get_model('contenttypes', 'ContentType')\n    sjt_ct = ContentType.objects.get_for_model(SystemJobTemplate)\n    now_dt = now()\n    schedule_time = now_dt.strftime('%Y%m%dT%H%M%SZ')\n\n    sjt, created = SystemJobTemplate.objects.get_or_create(\n        job_type='cleanup_sessions',\n        defaults=dict(\n            name='Cleanup Expired Sessions',\n            description='Cleans out expired browser sessions',\n            polymorphic_ctype=sjt_ct,\n            created=now_dt,\n            modified=now_dt,\n        ),\n    )\n    if created:\n        sched = Schedule(\n            name='Cleanup Expired Sessions',\n            rrule='DTSTART:%s RRULE:FREQ=WEEKLY;INTERVAL=1' % schedule_time,\n            description='Cleans out expired browser sessions',\n            enabled=True,\n            created=now_dt,\n            modified=now_dt,\n            extra_data={},\n        )\n        sched.unified_job_template = sjt\n        sched.save()\n\n\ndef create_cleartokens_jt(apps, schema_editor):\n\n    SystemJobTemplate = apps.get_model('main', 'SystemJobTemplate')\n    Schedule = apps.get_model('main', 'Schedule')\n    ContentType = apps.get_model('contenttypes', 'ContentType')\n    sjt_ct = ContentType.objects.get_for_model(SystemJobTemplate)\n    now_dt = now()\n    schedule_time = now_dt.strftime('%Y%m%dT%H%M%SZ')\n\n    sjt, created = SystemJobTemplate.objects.get_or_create(\n        job_type='cleanup_tokens',\n        defaults=dict(\n            name='Cleanup Expired OAuth 2 Tokens',\n            description='Cleanup expired OAuth 2 access and refresh tokens',\n            polymorphic_ctype=sjt_ct,\n            created=now_dt,\n            modified=now_dt,\n        ),\n    )\n    if created:\n        sched = Schedule(\n            name='Cleanup Expired OAuth 2 Tokens',\n            rrule='DTSTART:%s RRULE:FREQ=WEEKLY;INTERVAL=1' % schedule_time,\n            description='Removes expired OAuth 2 access and refresh tokens',\n            enabled=True,\n            created=now_dt,\n            modified=now_dt,\n            extra_data={},\n        )\n        sched.unified_job_template = sjt\n        sched.save()\n", "path": "awx/main/migrations/_create_system_jobs.py"}]}