mysql的定时任务

参考博客:https://blog.csdn.net/qq_26562641/article/details/53301407

查看event是否开启: show variables like '%sche%';  

event_scheduler ON                         --------》表示已开启
performance_schema OFF
performance_schema_events_waits_history_long_size 10000
performance_schema_events_waits_history_size 10
performance_schema_max_cond_classes 80

.........

将事件计划开启: set global event_scheduler=1; 

关闭事件任务: alter event e_test ON COMPLETION PRESERVE DISABLE; 
开户事件任务: alter event e_test ON COMPLETION PRESERVE ENABLE; 

查看任务列表

SELECT * FROM information_schema.events; 

创建一个简单的计划任务,这里调用的是存储过程。do 后面也可以跟sql

 CREATE EVENT if not exists e_test 
          on schedule every 30 second 
          on completion preserve 
     do call test(); 

猜你喜欢

转载自www.cnblogs.com/coder-lzh/p/9419765.html