Reply
Highlighted
Explorer
Posts: 14
Registered: ‎07-06-2018

How to get file or directory creation time in HDFS?

Hi All,

 

How to get file or directory creation time in HDFS?

I know this sounds very basic question. I have googled on this, this question was asked on Internet, but people respond with modification time instead of creation time.

I am not intrested to get modification time. I am interested to know how get creation time of a file or directory on HDFS.

Appreciate if anyone have the answer to this.

 

rgds,

Rama.

Posts: 1,903
Kudos: 435
Solutions: 305
Registered: ‎07-31-2013

Re: How to get file or directory creation time in HDFS?

HDFS only stores two time points in its INode data structures/persistence: The modification time and the access time [1].

For files, the mtime is effectively the time of when the file was last closed (such as when originally written and closed, or when reopened for append and closed). In general use this does not change very much for most files you'll place on HDFS and can serve as a "good enough" creation time.

Is there a specific use-case you have in mind that requires preservation of the original create time?

[1] https://github.com/apache/hadoop/blob/trunk/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache...