[Techtalk] file creation date

Miriam English mim at miriam-english.org
Sat Apr 7 06:58:21 UTC 2012


Whew! Hours later I finally found what I was wanting. (+10 points for 
perseverance, but -10 points for distractability. I was supposed to be 
writing today. Damn!)

So, it looks like I'll be moving to ext4. For you lucky folks who are 
already using a recent version of Ubuntu you will probably find it 
formatted your disks as ext4 by default.

Because the standard Linux tools can't see creation date yet you need a 
bit of a hack to get at it on ext4. First see if the device is actually 
formatted as ext4 by typing:

mount

Now, presuming the file you want to find the creation date for is called 
"/stuff/subdir/blah.txt" and is on device "/dev/sdf1" then you can use:

debugfs -R 'stat /stuff/subdir/blah.txt' /dev/sdf1

This is very clunky, but I'm sure a little more thought will let me wrap 
this into a little bash script to give just the creation time instead of 
12 lines of all the inode data. The file creation date is given on the 
output line that starts with "crtime".

Yay!

Some time later (not today -- I'm supposed to writing) I must work out 
how to set the creation date for files where I have that data recorded.

Cheers,

	- Miriam

P.S. I found this nice trick in a cool blog by Alina Swietochowska at
http://www.qa.com/about-qa/blogs/2010/july/creation-time-in-unix-yes-in-ext4/


Little Girl wrote:
> Hey there,
>
> Miriam English wrote:
>
>> I've often been in situations where it would be very useful (or
>> even necessary) for Linux to have a creation date instead of merely
>> change, modify, access. It seems like a sensible thing to have,
>> right? Much more sensible than change AND modify, which seems like
>> unnecessary duplication.
>
> Yes, yes, yes - oh, that would be wonderful!
>
>> Yes, I know that change is supposed to track status bits and modify
>> is supposed to track file contents (and I can never remember which
>> is which because the words "change" and "modify" are synonyms), but
>> in practice an alteration to the file itself usually changes both
>> dates anyway, so a separate date for status bits is almost useless
>> because it only adds any extra info if the status bits were altered
>> without changing the file. Okay, I can imagine some rare security
>> situations where that might be useful, like tracking an intruder's
>> footprints. But I can see very common uses for a file creation date.
>
> I can imagine that all of them are useful for different purposes, and
> have had a need for a file creation date many times. There are times
> when you want to know which file or directory you created before
> another one, or which was the first script you ever wrote, etc.,
> etc., etc. I've found it repeatedly frustrating that all I can see is
> when I last did something to a file.
>
>> I was looking on the net for other ideas on how I might be able to
>> get around the lack of creation date and I read that the ext4
>> filesystem designers were thinking of adding creation date to its
>> inode descriptors. I have to say, it is about time this was done. I
>> was struck by the number of questions on the net by people wanting
>> to use file creation date in Linux.
>
> I am so happy to hear this! I'm one of the people who wants it. (:
>

-- 
If you don't have any failures then you're not trying hard enough.
  - Dr. Charles Elachi, director of NASA's Jet Propulsion Laboratory
-----
Website: http://miriam-english.org
Blogs:   http://miriam-e.dreamwidth.org
          http://miriam-e.livejournal.com


More information about the Techtalk mailing list