Search code examples
linuxhadoophdfsput

Unable write current date to the HDFS directory


I want to write current date to a file in HDFS, so that i can read it for next run. Eg: from the below command i want to write 2021-08-03 08:43:37 to HDFS directory /user/maria_dev/satheesh/temp. I tried below, but didn't work. Any suggestions please?

echo `date '+%Y-%m-%d %H:%M:%S' | hadoop fs -put - /user/maria_dev/satheesh/temp


Solution

  • Basically it is wring the date to the HDFS directory using put command and - as file name. When I do cat I am getting the date.

    echo `date '+%Y-%m-%d %H:%M:%S' | hadoop fs -put - /user/maria_dev/satheesh/temp'

    [maria_dev@sandbox-hdp ~]$ hadoop fs -cat /user/maria_dev/satheesh/temp/*

    Output: 2021-08-03 08:39:58