Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

a file's mtime is not reliable when rotating log by datetime #135

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

wangcn
Copy link

@wangcn wangcn commented Nov 28, 2016

test code

package main

import (
	"os"
	"time"
	"fmt"
)


func main() {
	t1 := time.Now()
	fmt.Println(t1)
	file, _ := os.Create("test.txt")
	stat, _ := file.Stat()
	t2 := stat.ModTime()
	fmt.Println(t2)
	fmt.Println(t2.Sub(t1))
}

t2 < t1.
my env: go1.7.3+openSUSE42.1+xfs
If rotating a log by comparing mtime and "now", the historical log may be overwritten multiple times and you lose it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant