Mysql Event scheduler

Posted on September 18, 2016 by Suresh Kamrushi in Mysql

I have already posted a blog (Event Scheduler an alternative to cronjob) with different advantages of Even scheduler over cron job, here I am sharing how you can configure MySql server to enable or disable scheduler and writing a sample event scheduler.
You can check with below query as your server is up for event scheduler or not.

SELECT @@event_scheduler;

Query will gives your “ON” or “OFF”. if it is off you can enable it as:

SET GLOBAL event_scheduler = ON;

Now you can create your own event scheduler as below:

CREATE EVENT suresh_test
INSERT INTO test_scheduler (`datetime`) VALUES (CURRENT_TIMESTAMP);

The above scheduler will runs every 10 second and insert a row in “test_scheduler” table.

  Comments or questions are welcome