i am using ubuntu and want to know the creation time of a file even when it gets modified or accessed ?
The closest attribute available is the "change time", also known as ctime
. This is updated for various system calls, any that modify the inode, rather than the data it contains.
matt@stanley:~$ stat -c %z .bashrc 2010-08-17 11:53:56.865431072 +1000
Links
Unfortunately Unix does not store the creation time of a file.
All you are able to get using stat is
- time of last access
- time of last modification
- time of last status change
Note: When using filesystem type ext4 crtime is available!
Further information:
According to http://en.wikipedia.org/wiki/Comparison_of_file_systems, this is available for ext4, btfrs, FAT, NTFS, and UDF filesystems, plus some others you're unlikely to encounter. It's not available on ext2 or ext3, probably the most common file system formats in Ubuntu.
You'll need a kernel patch, though: http://lwn.net/Articles/394391/. Apparently this is because Linus rejected creation time attribute on the grounds that somebody called it an "otime" and somebody else called it a "btime", and therefore the idea must be useless.
guys i just finished writing this script this script to find the creation date of a file using perl:
use File::stat;
if ( scalar( @ARGV ) == 0 ) {
die("type a file name ex:perl filestat.pl <filename>");
}
my $filename = $ARGV[0] ;
my @info = stat($filename);
print "Creation time :",scalar localtime stat($filename)->ctime;
print "\n";