Run a periodic cleanup task inside MySQL.
Section: triggers and events
Create a scheduled event
sql
sql
CREATE EVENT ev_purge_expired_sessions
ON SCHEDULE EVERY 1 DAY
DO
DELETE FROM sessions WHERE expires_at < NOW();Explanation
The event scheduler can automate recurring maintenance tasks inside the database.
Learn the surrounding workflow
Compare similar commands or jump into common fixes when this command is part of a bigger troubleshooting path.
Related commands
Same sheet · prioritizing triggers and events