Mysql event does not run at specified time

Asked

Viewed 49 times

0

I created an event in mysql so that every day on time 00:05:00 Starting on 07/18/2021, it performs an update on a table, only it is not running at the given time, what might be happening? Follow the script I used to create the Event

OBS.: He even made the first execution (the day I created the event), but did not repeat in the other days, even configured as a recurring event.

CREATE DEFINER=`root`@`localhost` EVENT `EventStatusUpdate`
    ON SCHEDULE
        EVERY 24 HOUR STARTS '2021-07-18 00:05:00'
    ON COMPLETION PRESERVE
    ENABLE
    COMMENT ''
    DO BEGIN

UPDATE usuario
SET   status = 1
WHERE status = 0;

END

  • Mysql is not my strong suit, but I suggest you take a closer look at the documentation CREATE EVENT Statement mainly in relation to CURRENT_TIMESTAMP

  • Thanks for replying @gleisin-dev, had already checked this and also Timezone are correct.

1 answer

0

"starting on 18/07/2021" this must be the problem, if you try to create an event with a retroactive date it will not work, the STARTS should always be a later date.

For example, at the time of this answer is "20/07/20121 15:00", so you can only schedule (in the case of your example) to start from "21/07/20121 00:05:00".

Create the event with STARTS for the next day and it will work.
Can also change the EVERY 24 HOUR STARTS for EVERY 1 DAY STARTS

Finally, don’t forget to confirm that the event was created correctly and also if Scheduler is active, otherwise it will not start the event next time. To confirm use the command SHOW PROCESSLIST, see if the list shows your event and the "event_scheduler", which is the agent that starts the scheduled events.

  • Thank you for answering Ricardo, actually when I scheduled for the day 18/07/2021 to start 00:05, I created before that, created on 17 some 23 hrs and I was waiting to see if he would perform even, then executed... I thought it was all right, But then for the rest of the days he didn’t. I had also tested with EVERY 1 DAY and it also didn’t work, I already have 2 days looking for a solution on the internet... also I gave a SHOW EVENTS and it is created and enabled, also I looked at the event_scheduler variable if it was active, Forgive me I missed pass also this information

  • I just saw the SHOW PROCESSLIST, it appeared here: Id User Host db Command Time State Info "5" "event_scheduler" "localhost" N "Daemon" "36560" "Waiting for next Activation" N "8" "root" "localhost:52082" "db_sistema" "Query" "0" "Starting" "SHOW PROCESSLIST" "9" "root" "localhost:52083" N "Sleep" "5" """ N I don’t know much about this command, there would have to appear a line with the name of the event I created?

  • I noticed here that yesterday the event performed at the right time (00:05) and today no longer performed again, what madness...

Browser other questions tagged

You are not signed in. Login or sign up in order to post.