先在hdfs系统创建文件夹logs
hadoop fs -mkdir /logs
编辑shell脚本 filemv.sh
#!/bin/bash
PATH=/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:/home/hadoop/jdk1.8.0_101/bin:/home/hadoop/hadoop-2.6.1/bin:/home/hadoop/hadoop-2.6.1/sbin:/home/hadoop/hadoop-2.6.1/bin:/home/hadoop/hadoop-2.6.1/sbin:/home/hadoop/bin
export $PATH
file=/home/hadoop/hadoop-2.6.1/logs;
if [ -s $file ]
then
for fi in `ls ${file}`
do
hadoop fs -moveFromLocal /home/hadoop/hadoop-2.6.1/logs/${fi} /logs/${fi}_copy ;
hadoop fs -ls /logs ;
done
fi
直接运行脚本进行测试
./filemv.sh