#/usr/bin/bash

#Tate:2022.6.6
#Author:Yingjian
#function: 定时清理mysql gocron 库表cron_task_log的日志数据
#env

workdir=`cd $(dirname $0);pwd`
seven_day_age=`date -d '-7 day' "+%F"`
mysql_bin=/usr/local/services/mysql/bin/mysql
user=gocron
password=******
host=lan.mysql.****.com
logfile=$workdir/gocron_clean.log

#echo $seven_day_age
echo "----`date` mysql gocron clean cron_task_log started sh------" >> $logfile

delete_sql="delete from cron_task_log where (start_time >= '${seven_day_age} 00:00:00' and start_time <= '${seven_day_age} 23:59:59' )"

$mysql_bin -h${host} -u${user} -p${password} -D${user} -e"${delete_sql}"

echo "----`date` mysql gocron clean cron_task_log end sh------" >> $logfile
