1

I am creating an event (like crone job) in MySQL to execute a query every 3 seconds but does not work. I tried my best. Here is my code please see if I am doing anything wrong

CREATE EVENT `croneJob` 
ON SCHEDULE EVERY 3 SECOND 
STARTS '2014-03-24 13:45:57' 
ON COMPLETION PRESERVE ENABLE 
DO 
insert into ranktable values (1,2,3);

It successfully creates it but does not execute every 3 seconds

0

3 Answers 3

2

You have to start your MySQL server events scheduler:

SET GLOBAL event_scheduler = ON;

Loot at:

https://dev.mysql.com/doc/refman/5.1/en/events-configuration.html

Sign up to request clarification or add additional context in comments.

Comments

2

As I know all events are executed by a special event scheduler thread.When we refer to the Event Scheduler, we actually refer to this thread.There is global event_scheduler system variable determines whether the Event Scheduler is enabled and running on the server.

Try to set the event_Scheduler on your command line.

SET GLOBAL event_scheduler = ON;

OR

SET GLOBAL event_scheduler = 1;

Read more about events.

Hope it will help you.

Comments

0

Even setting

SET GLOBAL event_scheduler = ON;

was not working so I put these lines in my.ini

[mysqld]
event_scheduler = ON

and is working great now.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.