Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Hdfs file timestamp

I want to get the last_modification time of file on hdfs. I checked HDFS shell guide but did not get any relevant command available.

Hadoop version is 2.4.0. Can anyone suggest how can I get last_modification time of hdfs file?

thanks in advance

like image 967
chhaya vishwakarma Avatar asked Sep 27 '22 08:09

chhaya vishwakarma


1 Answers

You can retrieve timestamp from hadoop ls command and parse it using awk.There is pattern for file/directory time stamp. For File it is

permissions number_of_replicas userid groupid filesize modification_date modification_time filename 

And Directory it is

permissions userid groupid modification_date modification_time dirname

6th and 7th field for file gives you modification date and time. You can use below sample for retrieving those information.

hadoop fs -ls /textfile | awk '{timestamp= $6  "  "  $7;print timestamp}'

Refer documentation for ls command.

http://hadoop.apache.org/docs/r2.7.0/hadoop-project-dist/hadoop-common/FileSystemShell.html Hope this will help.

like image 119
Shashi Avatar answered Oct 03 '22 06:10

Shashi