计划任务没有 运行

Scheduled task doesn't run

CREATE EVENT `set_trips_finished`
  ON SCHEDULE EVERY 1 DAY STARTS '2015-08-25 01:50:00'
  ON COMPLETION PRESERVE
DO BEGIN

  UPDATE trips
  SET status = 0
  WHERE date(created_at) < curdate();

END;

是定时任务。但是字段不会更新。当我 运行 只是查询时 - 字段更新正常。

我有另一个计划任务,语法完全相同,只是计划在 5 分钟后 运行,它 运行 没问题。

我不明白为什么不执行此任务 运行,或者查询是否不更新 table...有什么建议吗?

更新

我删除了另一个计划任务(正在运行的那个),然后重新设置它们,现在都没有触发...

查看事件调度器是否偶数运行ning:

show variables where variable_name='event_scheduler';
+-----------------+-------+
| Variable_name   | Value |
+-----------------+-------+
| event_scheduler | OFF   |
+-----------------+-------+

没有

创建我的测试table:

create table trips
(   id int auto_increment primary key,
    status int not null,
    created_at date not null
);
insert trips(status,created_at) values (0,'2014-09-09');

创建我的活动:

DELIMITER $$
CREATE EVENT `set_trips_finished`
  ON SCHEDULE EVERY 1 MINUTE STARTS '2015-08-23 00:00:00'
  ON COMPLETION PRESERVE
DO BEGIN

  UPDATE trips
  SET status = status+1
  WHERE date(created_at) < curdate();

END;$$
DELIMITER ;

按架构名称列出所有事件:

show events from so_gibberish;

or

show events\G; -- <--------- I like this one from mysql> prompt
show events; -- <--------- from workbench / sqlyog


*************************** 1. row ***************************
                  Db: so_gibberish
                Name: set_trips_finished
             Definer: GuySmiley@localhost
           Time zone: SYSTEM
                Type: RECURRING
          Execute at: NULL
      Interval value: 1
      Interval field: MINUTE
              Starts: 2015-08-23 00:00:00
                Ends: NULL
              Status: ENABLED
          Originator: 1
character_set_client: utf8
collation_connection: utf8_general_ci
  Database Collation: utf8_general_ci

查看可能更新状态的数据:

select * from trips;
+----+--------+------------+
| id | status | created_at |
+----+--------+------------+
|  1 |      0 | 2014-09-09 |
+----+--------+------------+

好吧,我可以等一整天,事件甚至都没有开启

SET GLOBAL event_scheduler = ON;    -- turn her on

show variables where variable_name='event_scheduler';
+-----------------+-------+
| Variable_name   | Value |
+-----------------+-------+
| event_scheduler | ON    |
+-----------------+-------+

等几分钟(注意我的事件每分钟 运行s)

select * from trips;
+----+--------+------------+
| id | status | created_at |
+----+--------+------------+
|  1 |      3 | 2014-09-09 |
+----+--------+------------+

事件有运行 3 次。好的,看起来不错

SET GLOBAL event_scheduler = OFF;   -- turn her off if so desired