add: rm expired backup file and shell script

This commit is contained in:
2023-10-28 16:23:54 +08:00
parent 6fe23761ab
commit 6370076362
5 changed files with 19 additions and 1 deletions

View File

@@ -5,7 +5,9 @@ import (
"fmt"
"ems.agt/lib/dborm"
"ems.agt/lib/global"
"ems.agt/lib/log"
"ems.agt/restagent/config"
"ems.agt/src/framework/cron"
)
@@ -71,7 +73,17 @@ func (s *BarProcessor) Execute(data any) (any, error) {
// delete expired files in backup directory
// todo ...
// command := fmt.Sprintf("find . -name '*.zip' -mtime +%d -type f -print | xargs rm -rf", duration)
command := fmt.Sprintf("%s/rmexpfiles.sh %s %d", config.GetYamlConfig().OMC.BinDir, config.GetYamlConfig().OMC.Backup, duration)
log.Trace("command:", command)
out, err := global.ExecCmd(command)
if err != nil {
log.Error("Faile to exec command:", err)
return nil, err
}
log.Trace("command output:", out)
// 返回结果,用于记录执行结果
return map[string]any{
"msg": "sucess",