Reputation: 117
How can I schedule a query to run using the MySQL scheduler (if that's the best method)? I followed the instructions from the link here but I'm a bit lost.
I would like to run the following query every 30 minutes on a particular database that we have.
update REQUESTS set status='expired' where status='pending' and date_sub(now(), interval 15 minute) > req_time;
Upvotes: 1
Views: 387
Reputation: 204904
delimiter //
CREATE EVENT IF NOT EXISTS your_event
ON SCHEDULE EVERY 30 MINUTE
STARTS '2014-07-25 12:00:00'
ON COMPLETION PRESERVE ENABLE
DO
update REQUESTS
set status='expired'
where status='pending'
and date_sub(now(), interval 15 minute) > req_time;
//
Upvotes: 2