LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Server (https://www.linuxquestions.org/questions/linux-server-73/)
-   -   file modification time smaller than a second (https://www.linuxquestions.org/questions/linux-server-73/file-modification-time-smaller-than-a-second-796086/)

thllgo 03-17-2010 02:00 PM

file modification time smaller than a second
 
Hello,

Is it possible to get file modification times measured to less than a second? Like milisecond, nanosecond, 10th of a second.

troop 03-17-2010 02:07 PM

yes.
Quote:

%N nanoseconds (000000000..999999999)
Code:

date -r /tmp "+%s/%N"
get seconds since 1970-01-01 00:00:00 UTC/nanoseconds

thllgo 03-17-2010 02:56 PM

Thanks. Your fix would have worked if the file system actually recorded the time at that granularity when the file was created. I tried the command on several files and everyone came out to 0 nanoseconds. I don't believe that is a likely scenario. I'm bummed.:(

chrism01 03-18-2010 04:05 AM

It depends on the filesystem
Quote:

Since kernel 2.5.48, the stat structure supports nanosecond resolution for the three file timestamp fields. Glibc exposes the nanosecond component of each field using names either of the form st_atim.tv_nsec, if the _BSD_SOURCE or _SVID_SOURCE feature test macro is defined, or of the form st_atimensec, if neither of these macros is defined. On file systems that do not support sub-second timestamps, these nanosecond fields are returned with the value 0.
http://linux.die.net/man/2/stat

If you know any C you can try it ...


All times are GMT -5. The time now is 07:31 PM.