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
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With