Create an Event
MySQL has its EVENT functionality for avoiding complicated cron interactions when much of what you are scheduling is SQL related, and less file related. See the Manual page here. Think of Events as Stored Procedures that are scheduled to run on recurring intervals.
To save time in debugging Event-related problems, keep in mind that the global event handler must be turned on to process events.
SHOW VARIABLES WHERE variable_name='event_scheduler';
With it OFF, nothing will trigger. So turn it on:
Schema for testing
The above inserts are provided to show a starting point. Note that the 2 events created below will clean out rows.
Create 2 events, 1st runs daily, 2nd runs every 10 minutes
Ignore what they are actually doing (playing against one another). The point is on the INTERVAL and scheduling.
Show event statuses (different approaches)
Random stuff to consider
DROP EVENT someEventName; -- Deletes the event and its code ON COMPLETION PRESERVE -- When the event is done processing, retain it. Otherwise, it is deleted.
Events are like triggers. They are not called by a user's program. Rather, they are scheduled. As such, they succeed or fail silently.
The link to the Manual Page shows quite a bit of flexibilty with interval choices, shown below:
Events are powerful mechanisms that handle recurring and scheduled tasks for your system. They may contain as many statements, DDL and DML routines, and complicated joins as you may reasonably wish.