create event shopCartCleanerListener on schedule every 1 day starts ‘2015-01-01 00:00:00‘ on completion preserve enable do update shopCart set cart = null;
show variables like ‘%sche%‘;
1、开启配置
set global event_scheduler =1;
2、创建定时任务,每天执行1次(on completion preserve代表永久执行)
CREATE EVENT IF NOT EXISTS whb_zzb_task
ON SCHEDULE EVERY 1 DAY
on completion preserve
DO
update mm_phone_detail set statusflag=2;
3、更改定时任务,5天执行1次
ALTER EVENT whb_zzb_task ON SCHEDULE EVERY 5 DAY;
4、开启任务
ALTER EVENT whb_zzb_task ENABLE;
5、关闭任务
ALTER EVENT whb_zzb_task DISABLE;
6、删除任务
DROP EVENT IF EXISTS whb_zzb_task
时间: 2024-10-10 05:32:49