如何在shell中捕获sqoop导入的成功执行?我想执行这样的后续导入:
result=$(sqoop import ...)
if [ $result > 0 ] ; then
sqoop import ...
else
exit 1
fi
(我知道这可以用oozie来完成,但是由于种种原因,我需要通过shell来完成)
您可以在shell脚本中尝试这种模式(例如run_sqoop.sh
)。
#!/bin/bash
sqoop import <rest-of-command-parameters>
result=$?
echo $result
if [ "$result" -eq 0 ] ; then
echo "OK"
else
echo "Fail"
echo "Fixing and running again"
sqoop import <updated-rest-of-command-parameters>
fi
使文件可执行
$ chmod 755 run_sqoop.sh
如果第一次导入成功,则输出将是:
output-logs-from-sqoop-command-execution
:
0
OK
如果第一次导入失败,则输出为:
output-logs-from-first-sqoop-command-execution
:
1
Fail
Fixing and running again
output-logs-from-second-sqoop-command-execution
:
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句