2017-02-05 1 views
0

start.sh beginnt erstellt copy_file.sh und übergibt es zwei ParameterKein Fehler beim Erstellen eines Verzeichnisses, aber kein Verzeichnis wurde

yeasterday_with_dash=2017-01-31 
today_without_dash=20170201 

echo "-----------RUN copy mta-------------" 
bash copy_file.sh mta $today_without_dash 
echo "-----------RUN copy rcr-------------" 
bash copy_file.sh rcr $today_without_dash 
echo "-----------RUN copy sub-------------" 
bash copy_file.sh sub $today_without_dash 

copy_file.sh ist supoosed zu überprüfen, ob ein Verzeichnis vorhanden ist und wenn es nicht schaffen.

hdfs_dir=/apps/hive/warehouse/mydb.db/fct_evkuzmin/${2}/file_${1} 

if hadoop fs -test -d $hdfs_dir ; then 
    echo "Directory "$hdfs_dir" exists" 
else 
    hadoop fs -mkdir $hdfs_dir 
    echo "Creating "$hdfs_dir 
fi 

Das Skript läuft erfolgreich scheint es.

Das Protokoll.

yeasterday_with_dash=2017-01-31 
today_without_dash=20170201 
-----------RUN copy mta------------- 
mkdir: `/apps/hive/warehouse/mydb.db/fct_evkuzmin/20170201/file_mta': No such file or directory 
Creating /apps/hive/warehouse/mydb.db/fct_evkuzmin/20170201/file_mta 
end copy mta files 
-----------RUN copy rcr------------- 
mkdir: `/apps/hive/warehouse/mydb.db/fct_evkuzmin/20170201/file_rcr': No such file or directory 
Creating /apps/hive/warehouse/mydb.db/fct_evkuzmin/20170201/file_rcr 
end copy rcr files 
-----------RUN copy sub------------- 
mkdir: `/apps/hive/warehouse/mydb.db/fct_evkuzmin/20170201/file_sub': No such file or directory 
Creating /apps/hive/warehouse/mydb.db/fct_evkuzmin/20170201/file_sub 
end copy sub files 

Aber es ist kein aktuelles Verzeichnis erstellt. Was ist das Problem?

+1

Können Sie es doppelt zitieren? 'hadoop fs -mkdir" $ hdfs_dir "' – Inian

Antwort

2

Verwenden Sie mkdir mit -p Argument, um auch übergeordnete Verzeichnisse zu erstellen.

hadoop fs -mkdir -p etc 
Verwandte Themen