LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
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: 296

Rep: Reputation: 32
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: 97
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: 296

Original Poster
Rep: Reputation: 32
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
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,359

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
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



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 06:25 PM
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

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

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

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration