shell 定时任务:
/usr/bin/mysql -uroot -pxxxxx databasename -e "update table set ......."
mysql event:
查看event是否开启:
mysql> show variables like '%sche%';
event_scheduler | ON
将事件计划开启 : SET GLOBAL event_scheduler = 1;
将事件计划关闭 : SET GLOBAL event_scheduler = 0;
关闭事件任务 : ALTER EVENT eventName ON COMPLETION PRESERVE DISABLE;
开启事件任务 : ALTER EVENT eventName ON COMPLETION PRESERVE ENABLE;
查看事件任务 : SHOW EVENTS ;
DELIMITER //
CREATE PROCEDURE yoon ()
BEGIN
update a SET id = 2 WHERE id = 1;
END //
create event if not exists e_yoon
on schedule every 10 second
on completion preserve
do
begin
call yoon();
end //
以上事件e_yoon表示每10秒执行一次yoon()