code: def clean_old_jobs():
      '''
      Called in the master's event loop every loop_interval.  Archives and/or
      deletes the events and job details from the database.
      :return:
      '''
      if __opts__.get('keep_jobs', False) and int(__opts__.get('keep_jobs', 0)) > 0:
          try:
              with _get_serv() as cur:
                  sql = "select (NOW() -  interval '{0}' hour) as stamp;".format(__opts__['keep_jobs'])
                  cur.execute(sql)
                  rows = cur.fetchall()
                  stamp = rows[0][0]
  
              if __opts__.get('archive_jobs', False):
                  _archive_jobs(stamp)
              else:
                  _purge_jobs(stamp)
          except Exception as e:
              log.error(ef clean_old_jobs():
      '''
      Called in the master's event loop every loop_interval.  Archives and/or
      deletes the events and job details from the database.
      :return:
      '''
      if __opts__.get('keep_jobs', False) and int(__opts__.get('keep_jobs', 0)) > 0:
          try:
              with _get_serv() as cur:
                  sql = "select (NOW() -  interval '{0}' hour) as stamp;".format(__opts__['keep_jobs'])
                  cur.execute(sql)
                  rows = cur.fetchall()
                  stamp = rows[0][0]
  
              if __opts__.get('archive_jobs', False):
                  _archive_jobs(stamp)
              else:
                  _purge_jobs(stamp)
          except Exception as e:
              log.error(e)
docs: Called in the master's event loop every loop_interval.  Archives and/or
      deletes the events and job details from the database.
      :return: