我有一个shell脚本,我想从oozie执行但它失败了。
#!/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-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 :(得分:0)
当我从shell脚本中删除第一行#!/usr/bin/ksh
时,它对我有用。但我不确定为什么它会失败。