如何在shell中成功捕获sqoop导入? 我想执行类似的后续导入:
apiVersion: rbac.authorization.k8s.io/v1beta1
kind: ClusterRoleBinding
metadata:
name: kubernetes-dashboard
labels:
k8s-app: kubernetes-dashboard
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: cluster-admin
subjects:
- kind: ServiceAccount
name: kubernetes-dashboard
namespace: kube-system
(我知道这可以用oozie来完成,但是由于种种原因,我需要通过shell来做到这一点)
答案 0 :(得分:0)
您可以在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
: