定时删除zabbix mysql数据

use zabbix; DELIMITER // create PROCEDURE delete_history() begin delete from history_log where to_days(now())-to_days(from_unixtime(clock))>90; delete from history_text where to_days(now())-to_days(from_unixtime(clock))>90; delete from history_str where to_days(now())-to_days(from_unixtime(clock))>90; delete from events where to_days(now())-to_days(from_unixtime(clock))>365; delete from auditlog where to_days(now())-to_days(from_unixtime(clock))>365; delete from alerts where to_days(now())-to_days(from_unixtime(clock))>365; delete from trends where to_days(now())-to_days(from_unixtime(clock))>365; delete from trends_uint where to_days(now())-to_days(from_unixtime(clock))>365; end; // DELIMITER ; SET GLOBAL event_scheduler = ON; create event deletehistoryplan ON SCHEDULE AT CURRENT_TIMESTAMP + INTERVAL 1 DAY do call delete_history();

你可能感兴趣的:(定时删除zabbix mysql数据)