ouqiang / gocron

定时任务管理系统
MIT License
5.8k stars 1.23k forks source link

怎么用curl命令定时删除gocron的日志 #259

Closed czxin788 closed 4 years ago

czxin788 commented 4 years ago

我用curl命令,想定时删除gocron的日志,结果报如下错误,请问我应该怎么写。

[root@zabbix-server conf]# curl -H "Content-Type: application/json" -X POST -d '{"time":"1495519926"}' http://localhost:5920/api/v1/tasklog/remove/1

{"code":1,"message":"参数time不能为空","data":null}
czxin788 commented 4 years ago

不用掉用api了,直接从数据库删除就可以: mysql -e "delete from gocron.task_log where end_time< date_add(current_timestamp(), interval -28 day) ;"

然后加入crontab即可

piaoyun commented 1 year ago

直接定时任务添加吗? mysql -e "delete from gocron.task_log where end_time< date_add(current_timestamp(), interval -28 day) ;"

czxin788 commented 1 year ago

对,我加入到了linux的crontab里面了 01 00 * mysql -e "delete from gocron.task_log where end_time< date_add(current_timestamp(), interval -28 day) ;"