如何捕获spark-submit作业的返回代码,我编写了一个shell脚本来传递参数并使用spark类运行spark Submit,我使用下面的代码捕获了返回代码,但它不起作用。run spark是我的一个函数运行带有spark类和参数的spark提交的shell脚本。
RunSpark
ret_code=$?
if [[ ${ret_code} != 0 ]]; then
exit ${ret_code} "Issue while executing spark class ${spark_class}"
fi
exit 0 echo "Script ran ok !"
除了错误的比较运算符之外-ne
,echo和exit是单独的命令,它们不能在同一行。另外,您应该在退出之前调用echo,否则脚本将不会打印任何内容。这应该工作:
# generating random numbers from 0 to 3, just for testing purposes
ret_code=$(( ( RANDOM % 4 ) ))
if [[ ${ret_code} -ne 0 ]]; then
echo "Issue while executing spark class ${spark_class}"
exit ${ret_code}
fi
echo "Script ran ok !"
exit 0
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句