Support Questions
Find answers, ask questions, and share your expertise
Announcements
Alert: Welcome to the Unified Cloudera Community. Former HCC members be sure to read and learn how to activate your account here.

How do I create the folder name with current timestamp in HDFS using NiFi ?

How do I create the folder name with current timestamp in HDFS using NiFi ?

New Contributor

I am trying to create the directory with current timestamp as the name of the folder in hdfs

what should I use to get the desire output ?


Right now my flow is : ListHDFS -----> Updateattribute ----->PutHDFS.




any suggestions please ?

1 REPLY 1

Re: How do I create the folder name with current timestamp in HDFS using NiFi ?

Super Guru

@Veerendra Nath Jasthi

In UpdateAttribute add new attribute as

ts

value as

${now():format("yyyy_MM_dd_HH_mm_ss_SSS")}

Example:

ts attribute will have value as 2019_06_12_20_42_26_762

Then in PutHDFS processor configure directory as

/<path>/${ts}

(or)

You can skip UpdateAttribute processor and directly use directory name as

/<path>/${now():format("yyyy_MM_dd_HH_mm_ss_SSS")}

In PutHDFS processor.

This will create a directory in HDFS with current timestamp value.

You can change the format of the timestamp using NiFi expression language.