Enabling MySQL scheduled tasks

Source: Internet
Author: User

Since MySQL5.1.0, an Event sched (Event sched) feature has been added, which can be used to regularly execute certain tasks (for example: delete records, summarize data, and so on) to replace jobs that can only be executed by scheduled tasks of the operating system. It is worth mentioning that the MySQL event scheduler can execute a task exactly every second, and the scheduled task of the operating system (such as CRON in Linux or task plan in Windows) it can be executed only once per minute. It is suitable for applications that require high real-time data (such as stocks, odds, and scores.

The event scheduler can also be called a temporary trigger (temporal triggers), because the event scheduler executes some tasks based on the Triggers triggered at a specific time period, and the trigger (triggers) is Triggered Based on the event generated by a table.

Check whether the event is Enabled:

Show variables like 'event % ';
SELECT @ event_scheduler;
Show processlist;

If event_schedist is on or PROCESSLIST shows event_schedist information, the event is enabled. If the event is off or the event_scheduler information cannot be viewed in PROCESSLIST, it indicates that the event is not enabled and we need to enable it.

Temporarily enable (mysql service becomes invalid after restart)

Set global event_scheduler = 1; // 0 indicates disabled

Enable permanently:

Add the following content in [mysqld] Of my. cnf and restart mysql (mysql restart command: service mysqld restart)

Event_scheduler = ON

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.