Tag:mysql timing
Before deleting data or changing data is to write a script on the server run timed tasks, Crontab wrote a lot of tasks, mysql 5.1 after the support of the incident can be very convenient to carry out; For example, I want to clear the clients table every night 23 o'clock. See if MySQL turns on event;show variables like ' Event_scheduler ' ; open Set global event_ scheduler =1; Create Event # change; to $$ on cmd command line delimiter $ $CREATE EVENT ' clients ' on SCHEDULE EVERY 1 DAY STARTS ' 2017-10-13 23:00:00 ' DO BEGIN #干你想干的事情 insert delete update can truncate table clients; end $ $DELIMITER ;# Daily execution is 1 day weekly 1 week hourly 1 Hour 1 minute View Event show events; If you want to set a few days later and do not want to calculate the time such as 5 days after the start of execution delimiter $ $CREATE EVENT ' clients ' on schedule every 1 day current_timestamp+ interval 5 day do begin #干你想干的事情 insert delete update can truncate table clients; End $ $DELIMITER ; If stops after 5 days add endsdelimiter $ $CREATE EVENT ' clients ' on schedule every 1 day ends endscurrent_timestamp+ interval 5 day DO BEGIN #干你想干的事情 insert delete update can truncate table clients; end $ $DELIMITER ;
mysql-Scheduled Task (event)