Our Community is getting an upgrade! To get everything ready for the relaunch, we’ll be placing the site in read-only mode starting September 21st.
We really appreciate your understanding while we get things set up behind the scenes. Catch up on all the exciting details about the move here.
Need help or have questions? Drop us a line at [email protected]

Archives of Support Questions (Read Only)

This is an archived board for historical reference. Information and links may no longer be available or relevant
Announcements
This board is archived and read-only for historical reference. To ask a new question, please post a new topic on the appropriate active board.

Hide "Connecting to namenode via..." message from stdout when using hdfs fsck in a for loop

avatar
Expert Contributor

Hello ,

I usually use for loops to get info of some folders.

For example: I had to find which folder inside /user/bigdata was consuming high number of blocks due to small files.

So i used this:

for i in $(hadoop fs -ls /user/bigdata/ | grep drwx | awk '{print $8}'); do echo "$i $(hdfs fsck $i -blocks -files -locations | grep BP- | wc -l)" ; done

Getting a lot of "Connecting to namenode via http://<hostname>:50070/fsck?ugi=hdfs&blocks=1&files=1&locations=1&path=%2Fuser%2Fbigdata%2F.<directory>" messages.

Does exist any way of hide this message? I currently have to redirect the output to a file and then use cat to read a clear infomation.

Thank you in advance.

1 ACCEPTED SOLUTION

avatar
Expert Contributor

Well finally I solved this.

The "Connecting to namenode via http://<hostname>:50070/fsck?ugi=hdfs█s=1&files=1&locations=1&path=%2Fuser%2Fbigdata%2F.<directory>" is the stderr output of the command so redirecting stderr to /dev/null does the work :).

for i in $(hadoop fs -ls /user/bigdata/ | grep drwx | awk '{print $8}'); do echo "$i $(hdfs fsck $i -blocks -files -locations 2> /dev/null | grep BP- | wc -l)" ; done

View solution in original post

1 REPLY 1

avatar
Expert Contributor

Well finally I solved this.

The "Connecting to namenode via http://<hostname>:50070/fsck?ugi=hdfs█s=1&files=1&locations=1&path=%2Fuser%2Fbigdata%2F.<directory>" is the stderr output of the command so redirecting stderr to /dev/null does the work :).

for i in $(hadoop fs -ls /user/bigdata/ | grep drwx | awk '{print $8}'); do echo "$i $(hdfs fsck $i -blocks -files -locations 2> /dev/null | grep BP- | wc -l)" ; done