master
huanghai 5 years ago
parent 2d85e7dc61
commit 90db0d002f

@ -49,20 +49,20 @@ func main() {
//创建日志文件目录 //创建日志文件目录
if !CommonUtil.Exists(ConfigUtil.DistributeRemotePath + "Logs") { if !CommonUtil.Exists(ConfigUtil.DistributeRemotePath + "Logs") {
os.MkdirAll(ConfigUtil.DistributeRemotePath+"Logs", os.ModePerm) _ = os.MkdirAll(ConfigUtil.DistributeRemotePath+"Logs", os.ModePerm)
} }
//添加定时清理垃圾的代码 //添加定时清理垃圾的代码
c := cron.New(cron.WithSeconds()) c := cron.New(cron.WithSeconds())
c.AddFunc("0 0 1 * * *", func() { _, _ = c.AddFunc("0 0 1 * * *", func() {
//清除导入数据的临时表 //清除导入数据的临时表
var db = DbUtil.Engine var db = DbUtil.Engine
sql := "truncate table t_base_teacher_import_excel" sql := "truncate table t_base_teacher_import_excel"
db.SQL(sql).Execute() _,_=db.SQL(sql).Execute()
sql = "truncate table t_base_student_import_excel" sql = "truncate table t_base_student_import_excel"
db.SQL(sql).Execute() _,_=db.SQL(sql).Execute()
//清空自动日志 //清空自动日志
var logPath = ConfigUtil.DistributeRemotePath + "Logs" var logPath = ConfigUtil.DistributeRemotePath + "Logs"
@ -70,7 +70,7 @@ func main() {
if CommonUtil.Exists(file) { if CommonUtil.Exists(file) {
f, _ := os.OpenFile(file, os.O_WRONLY|os.O_TRUNC, 0600) f, _ := os.OpenFile(file, os.O_WRONLY|os.O_TRUNC, 0600)
defer f.Close() defer f.Close()
f.WriteString("清空成功!") _,_=f.WriteString("清空成功!")
} }
}) })
c.Start() c.Start()

Loading…
Cancel
Save