So, you want some maintenance to run on MySQL, but you hate cron. Have no fear, events are here!
Here’s an example that came up in a work IRC channel for inserting a row on the last Tuesday of every month:
DELIMITER //
CREATE EVENT x ON SCHEDULE EVERY 1 DAY DO BEGIN
IF DAYOFWEEK(CURRENT_DATE)=3
AND
MONTH(CURRENT_DATE)<>MONTH(CURRENT_DATE + INTERVAL ‘7′
DAY)
THEN
INSERT INTO t VALUES (120);
END IF;
END//
You could also set it for EVERY 1 WEEK and omit the step of checking if it is Tuesday.
There is an article on events at http://dev.mysql.com/tech-resources/articles/event-feature.html
So what’s the catch? You need MySQL …
[Read more]