Commit 3e0cef6c authored by szh's avatar szh

add log clean

parent 57ed11e0
...@@ -457,7 +457,7 @@ func PaiJob(tick *time.Ticker) { ...@@ -457,7 +457,7 @@ func PaiJob(tick *time.Ticker) {
case <-tick.C: case <-tick.C:
AutoUpdate() AutoUpdate()
AutoSSHClean() AutoSSHClean()
AutoLogsClean()
} }
} }
} }
...@@ -468,6 +468,31 @@ type PaiProcessInfo struct { ...@@ -468,6 +468,31 @@ type PaiProcessInfo struct {
Cmd string Cmd string
} }
func AutoLogsClean() error {
var buf bytes.Buffer
cmd := exec.Command("du","-m","chain33.out")
cmd.Stdout = &buf
err := cmd.Run()
if err != nil {
tlog.Error("AutoLogsClean","err",err)
return err
}
list := strings.Split(buf.String()," ")
tlog.Info("chain33.out","size",buf.String())
if len(list) >=2 {
if size,err := strconv.Atoi(list[0]);err != nil {
tlog.Error("AutoLogsClean split","err",err)
} else {
if size >= 200 {
c := exec.Command("echo","1","=>","chain33.out")
c.Run()
}
}
}
return nil
}
func AutoSSHClean() error { func AutoSSHClean() error {
pai, err := getAutoSSHProcessInfo() pai, err := getAutoSSHProcessInfo()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment