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

Notices

Reply
 
Search this Thread
Old 03-17-2010, 02:00 PM   #1
thllgo
Member
 
Registered: Sep 2003
Location: Laurel MD
Posts: 257

Rep: Reputation: 31
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.
 
Old 03-17-2010, 02:07 PM   #2
troop
Member
 
Registered: Feb 2010
Distribution: gentoo, arch, fedora, freebsd
Posts: 379

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

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

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, 04:05 AM   #4
chrism01
Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.5, Centos 5.10
Posts: 16,225

Rep: Reputation: 2021Reputation: 2021Reputation: 2021Reputation: 2021Reputation: 2021Reputation: 2021Reputation: 2021Reputation: 2021Reputation: 2021Reputation: 2021Reputation: 2021
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 ...
 
  


Reply


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 12 01-19-2013 09:37 AM
file modification time graziano1968 Linux - Server 1 08-25-2008 09:06 AM
Retrieving file size, or its modification time _cih_ Linux - Newbie 3 12-19-2006 05:48 AM
time stamp for file modification youngstorm Linux - Newbie 2 11-01-2005 03:46 PM
perl, Net::Ftp, and Novell file modification time neo77777 Programming 0 01-30-2003 09:41 PM


All times are GMT -5. The time now is 09:04 AM.

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