Skip to content

Instantly share code, notes, and snippets.

@peijiehu
Created October 28, 2016 23:08
Show Gist options
  • Save peijiehu/afed53158abaa390fd8a0b32cd250e17 to your computer and use it in GitHub Desktop.
Save peijiehu/afed53158abaa390fd8a0b32cd250e17 to your computer and use it in GitHub Desktop.
SHOW events;
DROP EVENT delete_old_posts;
CREATE EVENT delete_old_posts
ON SCHEDULE EVERY 1 DAY STARTS '2016-10-28 08:00:00'
-- !!! no *END*: will continue until you explicitly drop the event
DO
DELETE FROM article WHERE inserted_at < DATE_SUB(NOW(), INTERVAL 7 DAY);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment