mysql event schedule,mysql Schedule Event每5分钟一次

I have the following script. The scripts runs but what i want is for it to run every 5 minutes following the wall clock time. Meaning it should run at 5, 10, 15 ... following the wall clock time at 5 minitues interval. What I can gauge for the result of the run is that the time is 10 - 30 seconds off. Is there a way to get it closer to the 5 minutues mark?. Thanks.

CREATE DEFINER=`root`@`%`

EVENT `run_event`

ON SCHEDULE EVERY 5 MINUTE STARTS '2016-04-06 00:00:00'

ON COMPLETION NOT PRESERVE ENABLE

DO CALL my_procedure

解决方案

Your configuration seems correct. The timing of events is not extremely precise, but it is reasonably precise -- enough that it shouldn't be half a minute off.

One interesting hack for event troubleshooting is to throw a warning from within the event. Since there is no client to which the warning can be sent, the warning is written to the MySQL error log. This should work in MySQL 5.5 and up:

DELIMITER $$

DROP EVENT IF EXISTS run_event $$

CREATE DEFINER=`root`@`%`

EVENT `run_event`

ON SCHEDULE EVERY 5 MINUTE STARTS '2016-04-06 00:00:00'

ON COMPLETION NOT PRESERVE ENABLE

DO

BEGIN

SIGNAL SQLSTATE '01000' SET MESSAGE_TEXT = 'run_event started';

CALL my_procedure;

SIGNAL SQLSTATE '01000' SET MESSAGE_TEXT = 'run_event finished';

END $$

It's been a while since I used this, but I believe the warnings will be written to the error log immediately, and not buffered until the event is finished.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值