srinivas amara
srinivas amara

Reputation: 155

How to find the hdfs files time stamp to milli seconds level

Is there a way we can get the time stamp of the files in HDFS to millisecond level.

For example:

in linux we can get the full time stamp like below

$ ls --full-time

total 4

-rw-r--r--. 1 bigdatauser hadoop 0 2017-09-15 01:09:25.068425282 -0400 newfile1.txt

-rwxrwxrwx. 1 bigdatauser hadoop 106 2017-09-15 01:08:16.791844270 -0400 test.sh

Upvotes: 0

Views: 2492

Answers (1)

tk421
tk421

Reputation: 5947

If you use hdfs dfs -stat '%Y' you can see the time in milliseconds.

$ hdfs dfs -touchz /tmp/test_file
$ hdfs dfs -stat "%Y" /tmp/test_file
1506621031648

From http://hadoop.apache.org/docs/stable/hadoop-project-dist/hadoop-common/FileSystemShell.html#stat:

Print statistics about the file/directory at in the specified format. Format accepts filesize in blocks (%b), type (%F), group name of owner (%g), name (%n), block size (%o), replication (%r), user name of owner(%u), and modification date (%y, %Y). %y shows UTC date as “yyyy-MM-dd HH:mm:ss” and %Y shows milliseconds since January 1, 1970 UTC. If the format is not specified, %y is used by default.

Upvotes: 4

Related Questions