mysql event 清理垃圾資料

2021-09-09 07:47:00 字數 1049 閱讀 7980

1.查詢是否開啟事件排程

show variables like 'event_scheduler';
2.開啟事件排程

臨時:set global event_scheduler = 1;

永久:vim /etc/my.cnf

event_scheduler=on

3.建立p_del_count儲存過程。

接收傳入引數30並執行刪除資料操作,刪除大於30天的資料。

drop procedure if exists p_del_count; 

create procedure p_del_count(in `date_inter` int)

begin

delete from t_req_log where (to_days(now()) - to_days(from_unixtime(unix_timestamp(time),'%y%m%d'))) >=date_inter;

end;

4.建立定時任務

從2018-05-15 00:00:00起每一天執行一次p_del_count這個儲存過程,並將引數傳給 

p_del_count儲存過程

drop event if exists e_del_t_req_log;

create event e_del_t_req_log

on schedule every 1 day starts '2018-05-15 00:00:00'

on completion not preserve enable do call p_del_count (30);

5.檢視已有定時事件任務

show events;

6.事件的開啟與關閉

開啟某事件:alter evente_del_t_req_logon completion preserve enable; 

關閉某事件:alter evente_del_t_req_logon completion preserve disable;

Ubuntu 清理垃圾

1 軟體快取清理命令 sudo apt get autoclean 清理舊版本的軟體快取 sudo apt get clean 清理所有軟體快取 sudo apt get autoremove 刪除系統不再使用的孤立軟體 這三個命令主要清理公升級快取以及無用包的。2 清理linux下孤立的包 圖形介...

kali清理垃圾記錄

sudo apt get autoclean 清理舊版本的軟體快取 sudo apt get clean 清理所有軟體快取 sudo apt get autoremove 刪除系統不再使用的孤立軟體使用 磁碟使用情況分析器檢視,發現 var log 占用空間比較大,特別是user.log 直接手動刪...

Docker垃圾清理方案

我們在使用docker的過程中發現基於swarm使用storage driver overlay的方式進行儲存.但是發現這個特別占用儲存空間.docker container prune停止的容器,不使用的volume,不使用的networks,懸掛的映象 docker system prune a...