启动时判断是否处于空闲时间决定是否执行fstrim

This commit is contained in:
刘祥超
2024-04-21 23:04:51 +08:00
parent c8f440e24c
commit b1e1c3ebbf
3 changed files with 16 additions and 4 deletions

View File

@@ -24,15 +24,17 @@ func NewTrimDisksTask() *TrimDisksTask {
// Start the task
func (this *TrimDisksTask) Start() {
// execute once
err := this.loop()
if err != nil {
remotelogs.Warn("TRIM_DISKS", "trim disks failed: "+err.Error())
if idles.IsMinHour() {
err := this.loop()
if err != nil {
remotelogs.Warn("TRIM_DISKS", "trim disks failed: "+err.Error())
}
}
var ticker = time.NewTicker(2 * 24 * time.Hour) // every 2 days
idles.RunTicker(ticker, func() {
// run the task
err = this.loop()
err := this.loop()
if err != nil {
remotelogs.Warn("TRIM_DISKS", "trim disks failed: "+err.Error())
}