Commit a500b268 authored by mcb's avatar mcb
parents eda389b1 d6170da2
...@@ -3,7 +3,6 @@ package com.jz.dmp.cmdexectool; ...@@ -3,7 +3,6 @@ package com.jz.dmp.cmdexectool;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.boot.Banner; import org.springframework.boot.Banner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.WebApplicationType; import org.springframework.boot.WebApplicationType;
import org.springframework.boot.actuate.health.Health; import org.springframework.boot.actuate.health.Health;
import org.springframework.boot.actuate.health.HealthIndicator; import org.springframework.boot.actuate.health.HealthIndicator;
...@@ -12,7 +11,6 @@ import org.springframework.boot.builder.SpringApplicationBuilder; ...@@ -12,7 +11,6 @@ import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.cache.annotation.EnableCaching; import org.springframework.cache.annotation.EnableCaching;
import org.springframework.context.ConfigurableApplicationContext; import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.transaction.annotation.EnableTransactionManagement; import org.springframework.transaction.annotation.EnableTransactionManagement;
import org.springframework.ui.freemarker.FreeMarkerConfigurationFactoryBean;
import com.jz.dmp.cmdexectool.common.utils.ApplicationContextUtil; import com.jz.dmp.cmdexectool.common.utils.ApplicationContextUtil;
import com.jz.dmp.cmdexectool.scheduler.service.process.ProcessService; import com.jz.dmp.cmdexectool.scheduler.service.process.ProcessService;
......
...@@ -5,20 +5,24 @@ src_dir=${src_dir!} ...@@ -5,20 +5,24 @@ src_dir=${src_dir!}
file_suffix="${file_suffix!}" file_suffix="${file_suffix!}"
# 要上传到hdfs的目录 # 要上传到hdfs的目录
des_dir=${des_dir!} des_dir=${des_dir!}
# 获取 src_dir 下所有文件为 file_suffix 的文件
cd ${src_dir}
if [ $file_suffix = "" ]; then if [ $file_suffix = "" ]; then
echo "没有后缀" echo "没有后缀"
filename="*" filename=`ls -l | grep ^- | awk '{print $9}'`
else else
filename="*.${file_suffix}" filename=`ls -l | grep ^- | awk '{print $9}' | grep .${file_suffix}`
fi fi
# 判断 hdfs 文件夹是否存在 # 获取当前系统时间
su hdfs -c "hdfs dfs -test -e ${des_dir}" time=`date +%Y%m%d%H%M%S`
des_dir=${r'"${des_dir}/${time}"'}
if [ $? -ne 0 ]; then echo "====================hdfs 文件夹不存在, 自动创建======================"
echo "====================hdfs 文件夹不存在, 自动创建======================" su hdfs -c "hdfs dfs -mkdir -p ${des_dir}"
su hdfs -c "hdfs dfs -mkdir -p ${des_dir}"
fi
su hdfs -c "hdfs dfs -put ${src_dir}/${filename} ${des_dir}/" for file in ${r'${filename}'}
\ No newline at end of file do
echo "正在上传hdfs的文件是: ${r'${src_dir}/${file}'}"
${r'su hdfs -c "hdfs dfs -put ${src_dir}/${file} ${des_dir}/"'}
done
\ No newline at end of file
#!/bin/bash
# 要上传到hdfs的来源目录
src_dir=${src_dir!}
# 要上传的文件类型
file_suffix="${file_suffix!}"
# 要上传到hdfs的目录
des_dir=${des_dir!}
cd $src_dir
if [ $file_suffix = "" ]; then
echo "没有后缀"
filename=`ls -l | grep ^- | awk '{print $9}'`
else
filename=`ls -l | grep ^- | awk '{print $9}' | grep .${file_suffix}`
fi
# 获取当前系统时间
time=`date +%Y%m%d%H%M%S`
des_dir=${r'"${des_dir}/${time}"'}
echo "====================hdfs 文件夹不存在, 自动创建======================"
su hdfs -c "hdfs dfs -mkdir -p ${des_dir}"
for file in ${r'${filename}'}
do
echo "正在上传hdfs的文件是: ${r'${src_dir}/${file}'}"
${r'su hdfs -c "hdfs dfs -put ${src_dir}/${file} ${des_dir}/"'}
done
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment