mysql event not running, scheduler is ON - mysql

I have a Mysql Event based on this answer:
https://stackoverflow.com/a/41099947/9478434
My Event is:
DELIMITER $$
CREATE
DEFINER=`db_admin`#`%`
EVENT dbname.my_event
ON SCHEDULE
EVERY 1 DAY
STARTS '2018-05-30 22:58:00'
COMMENT 'Do Archive old posts'
DO
BEGIN
CALL stored_procedure_1();
CALL stored_procedure_2();
END;
END $$
DELIMITER ;
But it does not run at the time it should run. I checked the event_scheduler variable and it is ON and in the processlist there is a record with Command: Sleep.

Related

MySQL script with event scheduler before spring boot app starts

In my app I creating tables with Hibernate annotations, but after this I want to create mysql script to generate raports:
In my resources folder I created data.sql :
DROP EVENT IF EXISTS daily_report;
DELIMITER $$
CREATE EVENT daily_report
ON SCHEDULE EVERY 1 DAY STARTS '2018-01-01'
ON COMPLETION PRESERVE
DO BEGIN
INSERT INTO daily_report(day_of_report,http_errors,other_errors) VALUES(
current_date(),
(select count(*) from error where date(save_date)=current_date() and name="HttpError"),
(select count(*) from error where date(save_date)=current_date() and name not in("unknown","HttpError")
));
END $$
DELIMITER ;
SET GLOBAL event_scheduler = ON;
All looks good, because when I run:
SELECT ##global.event_scheduler;
It shows that is ON, but after running:
show events
It shows no events :(
data.sql script is working because when I run him directly in mysql it works - command show events showing that this daily_report scheduled event is working.

MYSQL Events syntax error

I am running this CREATE EVENT query below, and it does create an event, but if I go in and look at the syntax in Edit Event I see a red x for END but no explanation. Therefore the event is not running, what do I have wrong? Thanks for the help in advance:
DELIMITER !
CREATE EVENT providers_import ON SCHEDULE EVERY 9 DAY_HOUR
ON COMPLETION PRESERVE ENABLE
COMMENT 'providers_old copied'
DO
BEGIN
DROP TABLE providers_old ;
CREATE TABLE providers_old LIKE providers ;
INSERT INTO providers_old SELECT * FROM providers GROUP BY Provider_Last_Name ;
END !
DELIMITER ;

MySql Event scheduler is not running

Below is the Event which I have written to be executed every day. I ran the SET GLOBAL event_scheduler = ON; before creating the event still it excutes only first day but from next day onwards it will not run.
Is there anything wrong in this query?
DELIMITER $$
ALTER DEFINER=`root`#`localhost` EVENT `Event1` ON SCHEDULE EVERY 1 DAY STARTS '2017-03-15 00:00:00' ON COMPLETION NOT PRESERVE ENABLE DO CALL UpdateLeaves()$$
DELIMITER ;
...ON COMPLETION NOT PRESERVE...
change to
...ON COMPLETION PRESERVE...

while using event scheduler in mysql it's working only one time

I am using mysql workbench6.3.7. I used event scheduler to execute the query everyday morning 9 o'clock I have used the following query
delimiter $$
create event eventtable
on schedule every '1' day
starts '2016-11-25 16:00:00'
do
begin
<statement>
end;
$$;
but it's working only one day it's not working daily.What am I missing??.Should i have to execute the query daily? Should I have to on the global scheduler daily? Please help me with this.
Thank you,
Jen
i have created following event for myself,That's working fine.look at this
CREATE DEFINER=`developer`#`%` EVENT `event_final_report_horn` ON SCHEDULE EVERY 2 MINUTE STARTS '2016-09-20 12:00:00' ON COMPLETION NOT PRESERVE ENABLE COMMENT 'Event generates horn final reports after completion of testing' DO BEGIN
if current_Time>='04:00:00' then
CALL hero_final_report_process_horn_data();
end if;
end

getting error when creating EVENT in MySQL

When i'm trying to create an EVENT in my MySQL getting this error
Script line: 1 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near
'EVENT `e_hourly`
ON SCHEDULE
EVERY 1 HOUR
COMMENT 'Clears out s' at line 1
I'm attaching my create EVENT code here
CREATE EVENT `e_hourly`
ON SCHEDULE
EVERY 1 HOUR
COMMENT 'Clears out sessions table each hour.'
DO call testing();#here i'm trying to call a stored proc
Your Event Code seems to be fine, perhaps you don't have support for events in your mysql version?
We usually format events as:
DELIMITER $$
DROP EVENT IF EXISTS E_Hourly$$
CREATE EVENT E_Hourly ON SCHEDULE EVERY 1 HOUR COMMENT 'Clears out sessions table each hour' DO
EV:BEGIN
CALL Testing();
END$$
DELIMITER ;
SET GLOBAL event_scheduler = ON;