#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2007
    Posts
    12
    Rep Power
    0

    How to get the file creation date ?


    well, im trying to list all files created today. The problem is , all i can find is the modification date. Even the options like -atime, ctime in find command refer to the modification date.

    Is there any command i could use for finding out file creation date ? or may be any other method ??

    Thanks for helping out.
  2. #2
  3. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2006
    Location
    Dublin, Ireland
    Posts
    174
    Rep Power
    45
    This depends on what filesystem you're using. Generally though the creation time isn't stored. Ctime actually records the time of the last status change. Changing permissions or renaming the file will result in the ctime being updated. Certain filesystems do record files' creation times, at least ZFS does anyway (crtime).
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2007
    Posts
    12
    Rep Power
    0
    Thanks. i went through the wiki on ZFS, and it is mentioned that it cannot be ported on Linux distros due to some licensing issue. So does that mean , theres no way of determining file creation date on a linux distro like Red Hat ??
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Regular (2000 - 2499 posts)

    Join Date
    Mar 2006
    Posts
    2,481
    Rep Power
    1752
    You will find that even with file sytems that hold creaton date (and I think most do) there is no way, direct from the shall prompt to obatin it. You will need to engage another programming environment (perl springs to mind) to show it.
    The moon on the one hand, the dawn on the other:
    The moon is my sister, the dawn is my brother.
    The moon on my left and the dawn on my right.
    My brother, good morning: my sister, good night.
    -- Hilaire Belloc
  8. #5
  9. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2007
    Posts
    12
    Rep Power
    0
    any hints on how can i go about doing that ? im pretty much a noob.
  10. #6
  11. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2007
    Posts
    12
    Rep Power
    0
    ok, i tried it with perl and i've managed to reach upto this point ,

    Code:
    perl -e 'use File::stat; 
    
    use Time::localtime; 
    
    $file='/mnt'; 
    
    $date_string = ctime(stat($file)->mtime); 
    
    print "file $file created at $date_string\n";'
    But when i try to run the script , i get error "search field incomplete".

    Please help.
  12. #7
  13. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2006
    Posts
    177
    Rep Power
    234
    you can try stat.
    Code:
    stat -c "%y" file
    check your man page.
  14. #8
  15. No Profile Picture
    ......@.........
    Devshed Beginner (1000 - 1499 posts)

    Join Date
    Jun 2004
    Posts
    1,345
    Rep Power
    56
    Shells and utilities like ls and date generally try to conform to a set of standards - POSIX.

    The standard says that three filetimes are recorded - access time, modification time, and inode change time - atime, mtime, ctime. It also says these three are the only filetimes that will be shown for a file.

    If you find a filesystem that supports a fourth filetime, creation time, it is actually an oddity, and most everything out there will not be able to support it.

    In fact, date -r <filename> shows mtime, according to the man page. stat does the same - only shows file modification time. And these are GNU extensions, available on with GNU utilities, and by default, on linux boxes. "Regular" unix distributions do not have stat and the -r option for date.

    The short answer is: there are no file creation times in UNIX. It is a windows thing.
  16. #9
  17. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2007
    Posts
    1
    Rep Power
    0

    time that file is update


    do you search this ?


    #! /usr/bin/perl
    use File::stat;
    use Time::localtime;
    $file='path//to/filename';
    $date_string =ctime(stat($file)->mtime);
    print "file $file update at $date_string\n";
  18. #10
  19. 63 dorinte
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2005
    Location
    Alleghany Highlands
    Posts
    130
    Rep Power
    230
    To add to the confusion, in FreeBSD (UFS) there is, in addition to the times of file access, file modification, and inode change,
    Code:
    $ stat -f %B $filename
    which the stat manpage claims to give "the birth time of the inode". So we can know the creation time of the inode, but not necessarily the creation time of the file.

    Curious .

    Ben N1NP

IMN logo majestic logo threadwatch logo seochat tools logo