Support Questions

Find answers, ask questions, and share your expertise

How to get file or directory creation time in HDFS?

avatar
Contributor

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.

1 REPLY 1

avatar
Mentor
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...