LinuxAnswers - the LQ Linux tutorial section.
Go Back > Forums > Linux Forums > Linux - Server
User Name
Linux - Server This forum is for the discussion of Linux Software used in a server related context.


  Search this Thread
Old 03-17-2010, 03:00 PM   #1
Registered: Sep 2003
Location: Laurel MD
Posts: 268

Rep: Reputation: 31
file modification time smaller than a second


Is it possible to get file modification times measured to less than a second? Like milisecond, nanosecond, 10th of a second.
Old 03-17-2010, 03:07 PM   #2
Registered: Feb 2010
Distribution: gentoo, arch, fedora, freebsd
Posts: 379

Rep: Reputation: 96
%N nanoseconds (000000000..999999999)
date -r /tmp "+%s/%N"
get seconds since 1970-01-01 00:00:00 UTC/nanoseconds

Last edited by troop; 03-17-2010 at 03:10 PM.
1 members found this post helpful.
Old 03-17-2010, 03:56 PM   #3
Registered: Sep 2003
Location: Laurel MD
Posts: 268

Original Poster
Rep: Reputation: 31
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.
Old 03-18-2010, 05:05 AM   #4
LQ Guru
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.7, Centos 5.10
Posts: 17,013

Rep: Reputation: 2245Reputation: 2245Reputation: 2245Reputation: 2245Reputation: 2245Reputation: 2245Reputation: 2245Reputation: 2245Reputation: 2245Reputation: 2245Reputation: 2245
It depends on the filesystem
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.

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


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Get file modification date/time in Bash script cmfarley19 Programming 16 04-15-2015 07:25 PM
file modification time graziano1968 Linux - Server 1 08-25-2008 10:06 AM
Retrieving file size, or its modification time _cih_ Linux - Newbie 3 12-19-2006 06:48 AM
time stamp for file modification youngstorm Linux - Newbie 2 11-01-2005 04:46 PM
perl, Net::Ftp, and Novell file modification time neo77777 Programming 0 01-30-2003 10:41 PM

All times are GMT -5. The time now is 05:01 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration