Finding when MySQL event last ran

42.2k Views Asked by At

I created an MySql event a few days ago. I don't think it has run. If I do SHOW EVENTS It started on 2015-09-07 00:00:00 and it has an interval of WEEK. Today is 2015-09-14 and it is well after midnight. It has a status of ENABLED. How do I know a) when it last ran, b) what it is supposed to do.

I created an SP which it was supposed to run. I tested this at the time but there is not sign that the SP has been run.

Is there any easy way to debug this? Or even a hard way?!

2

There are 2 best solutions below

4
On BEST ANSWER

This information is available through events in INFORMATION_SCHEMA. See LAST_EXECUTED column:

SELECT * FROM INFORMATION_SCHEMA.events;

You can also use SHOW CREATE EVENT yourevent to see what it does.

0
On

You can show all events in more detail than SHOW EVENTS with the SQL below, then LAST_EXECUTED column shows when they last ran. *The doc explains INFORMATION_SCHEMA.events table and I recommend to use \G which can show them more clearly and my answer explains how to show events with SHOW EVENTS:

SELECT * FROM INFORMATION_SCHEMA.events;

Or:

SELECT * FROM INFORMATION_SCHEMA.events\G

And, you can show all the events running currently with the SQL below:

SELECT * FROM INFORMATION_SCHEMA.events WHERE STATUS = 'ENABLED';

Or:

SELECT * FROM INFORMATION_SCHEMA.events WHERE STATUS = 'ENABLED'\G

And, you can show all the events not running currently with the SQL below:

SELECT * FROM INFORMATION_SCHEMA.events WHERE STATUS = 'DISABLED';

Or:

SELECT * FROM INFORMATION_SCHEMA.events WHERE STATUS = 'DISABLED'\G