Integration

MySQL has a built-in event query scheduling feature for one-time and repeating queries called the Event Scheduler.

Check it's enabled

Ensure the event_scheduler global variable is 'ON':

show global variables like 'event_scheduler';

You should also see a process from the event_scheduler user with Command of 'Daemon' and State of 'Waiting for next activation'.

List scheduled events

List events:

show events;

Schedule an event

Scchedule a recurring event every day for a month:

create event delete_old_events
 on schedule every 1 hour
      starts current_timestamp
        ends current_timestamp + interval 7 day
          do delete
        from events
       where created_at > now() - interval 1 month
       limit 1000;

Remove events

Drop an event:

drop event delete_old_events;