Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Event scheduling on startup mysql

Tags:

mysql

I have created some event. It is running on the time on which I have created it. But I want to run the event when ever mysql server is started. For Example I have created an event called CL_PL_CREDIT code looks like,

delimiter |

CREATE EVENT RURALSHORES2.UpLv
    ON SCHEDULE
      EVERY 1 MONTH
    DO
      BEGIN
      update emp_lv_rem set cl_count=cl_count+1,pl_count=pl_count+1.25 where emp_id in (select emp_id from emp_main where EmploymentType="Permanent" or EmploymentType="Regular");
      update emp_lv_rem set cl_count=1,pl_count=1 where emp_id in (select emp_id from emp_main where EmploymentType="Probation");
      update emp_lv_rem set cl_count=1,pl_count=0 where emp_id in (select emp_id from emp_main where EmploymentType="Contract" or EmploymentType="Partime" or EmploymentType="Trainee" or EmploymentType="Consultant");
update emp_lv_rem set cl_count=0,pl_count=0 where emp_id in (select emp_id from emp_main where EmploymentType="Contract" and EmploymentType<>"Partime" and EmploymentType<>"Trainee" and EmploymentType<>"Consultant" and EmploymentType="Permanent" and EmploymentType="Regular" and EmploymentType="Probation");

    END |;

delimiter ;

When I type show events it is showing as starts 2013-08-23 10:42:53, but I want to run it on every 1st day of month when ever server starts.

like image 551
Santosh Avatar asked Nov 12 '22 23:11

Santosh


1 Answers

In order to execute it every 1st day of month you should add the start date:

ON SCHEDULE
  EVERY 1 MONTH
  STARTS AT '2013-09-01 00:00:00'
like image 197
RenkyaZ Avatar answered Nov 15 '22 05:11

RenkyaZ