|
@@ -1,10 +1,14 @@
|
|
|
package timetask
|
|
|
|
|
|
import (
|
|
|
- "jy/src/jfw/nodemgr"
|
|
|
+ qutil "app.yhyue.com/moapp/jybase/common"
|
|
|
+ "jy/src/jfw/config"
|
|
|
+ "fmt"
|
|
|
+ "jy/src/jfw/nodemgr"
|
|
|
"app.yhyue.com/moapp/jypkg/public"
|
|
|
"log"
|
|
|
- "time"
|
|
|
+ "math"
|
|
|
+ "time"
|
|
|
|
|
|
"app.yhyue.com/moapp/jybase/redis"
|
|
|
|
|
@@ -46,6 +50,13 @@ func updateHotKeys() {
|
|
|
}
|
|
|
}
|
|
|
})
|
|
|
+ c.AddFunc("0 1 * * 1", func() { //每月1号清理匿名用户日志表 保留最近30天
|
|
|
+ tm:=time.Now().AddDate(0,0,-qutil.IntAllDef(config.Sysconfig["anonymousTime"],30)).Unix()
|
|
|
+ count := public.BaseMysql.CountBySql(fmt.Sprintf(`SELECT count(*) FROM anonymous_identity WHERE creation_time < %d and refer = '' and fid is null`,tm))
|
|
|
+ for i := 0; i < int(math.Ceil(float64(count)/float64(2000))); i++ {
|
|
|
+ public.BaseMysql.SelectBySql(fmt.Sprintf(`DELETE FROM anonymous_identity WHERE creation_time < %d and refer = '' AND fid IS NULL LIMIT 2000;`,tm))
|
|
|
+ }
|
|
|
+ })
|
|
|
c.Start()
|
|
|
defer c.Stop()
|
|
|
chan bool(nil) <- true
|