2016-03-29 50 views
0

我有一個shell腳本,我想從oozie執行但它是失敗的。shell腳本調用失敗oozie

shell腳本(test1.sh): -

#!/usr/bin/ksh 
. $PWD/test1.param 

kinit -k -t /home/$USER_ID/"$USER_ID".keytab $USER_ID 

for tablename in $tablelist 
do 
    for filename in `hadoop fs -ls $sqoop_dir/$tablename|awk '{print $8}'|rev|awk -F '/' '{print $1}'|rev` 
    do 
     hadoop fs -mv $sqoop_dir/$tablename/"$filename" $archive_dir/$tablename/"$filename"_`date +%Y%m%d%H%M%S` 
    done 
done 

exit 0 

參數文件: -

export sqoop_dir=/user/hduser/staging 
export archive_dir=/user/hduser/archive 
export tablelist="table1 table2 table3 table4 table5" 
export USER_ID=superusr1 

Workflow.xml: -

<workflow-app xmlns="uri:oozie:workflow:0.4" name="test1_wf"> 
     <credentials> 
       <credential name="hive2_cred" type="hive2"> 
         <property> 
           <name>hive2.jdbc.url</name> 
           <value>${hive2_jdbc_uri}</value> 
         </property> 
         <property> 
           <name>hive2.server.principal</name> 
           <value>${hive2_server_principal}</value> 
         </property> 
       </credential> 
     </credentials> 

     <start to="move_stg_files_to_archive"/> 

     <action name="move_stg_files_to_archive"> 
      <ssh xmlns="uri:oozie:ssh-action:0.1"> 
      <host>${user_host_name}</host> 
       <command>home/hduser/scripts/test1.sh</command>    
      </ssh> 
     <ok to="dly_load_wf_complete"/> 
      <error to="fail"/> 
     </action> 

<kill name="fail"> 
<message>Workflow failed, error message[${wf:errorMessage(wf:lastErrorNode())}]</message> 
</kill> 

<end name="dly_load_wf_complete"/> 
</workflow-app> 

shell腳本成功運行時單獨手動執行。

回答

0

當我從shell腳本中刪除第一行#!/usr/bin/ksh時,它對我有效。但我不確定爲什麼它會因此而失敗。