Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Event Scheduler should execute every month

I have Win XP os and XAMPP installed in my machine.

I need to execute my event/scheduler at 12:00:00 AM of First day of every month. Means 1st of every month. (e.g. jan 1st, Feb1 1st, March 1st, ... ).

And I also need to call the stored procedure in the same event. And I want achieve all this using Event/Job only not from front end.

Please spend few minutes for my query.

like image 511
Gnanendra Avatar asked Apr 19 '11 05:04

Gnanendra


People also ask

How do I create a recurring event in MySQL?

Creating new MySQL events First, specify the name of the event that you want to create the CREATE EVENT keywords. The event names must be unique within the same database. Second, specify a schedule after the ON SCHEDULE keywords. Third, place SQL statements after the DO keyword.

How do I run a stored procedure everyday in MySQL?

run this command : SET GLOBAL event_scheduler = ON; If ERROR 1229 (HY000): Variable 'event_scheduler' is a GLOBAL variable and should be set with SET GLOBAL: mportant.

What is event scheduler in MySQL?

The MySQL Event Scheduler manages the scheduling and execution of events, that is, tasks that run according to a schedule.

How do I know if MySQL event is running?

SELECT * FROM INFORMATION_SCHEMA. events; You can also use SHOW CREATE EVENT yourevent to see what it does.


1 Answers

The MySQL event syntax is very simple -

DELIMITER $$
CREATE EVENT event1
ON SCHEDULE EVERY '1' MONTH
STARTS '2011-05-01 00:00:00'
DO 
BEGIN
 -- your code
END$$

DELIMITER ;

Event will start working on '2011-05-01' at '00:00:00' (datetime must be in a future).

More information - Using the Event Scheduler

Do not forget to enable global event scheduling thread -

SET GLOBAL event_scheduler = 1;
like image 192
Devart Avatar answered Oct 16 '22 22:10

Devart