crontab执行feat_gen.sh时,报错找不到pyspark

crontab执行feat_gen.sh时,报错找不到pyspark module
解决办法:在bash脚本中添加source ~/.bash_profile这一行在行首。其中在~/.bash_profile中配置好PATH和PYTHONPATH(把$SPARK_HOME下的python加到PYTHONPATH中即可)

feat_gen.sh:
source ~/.bash_profile

python3 ~/cust_loss_feature/pipeline.py 1>~/cust_loss_feature/exe.log 2>~/cust_loss_feature/err.log

在~/.bash_profile中:

export PATH=$SPARK_HOME/bin:$PATH
export PYTHONPATH=$SPARK_HOME/python/:$SPARK_HOME/python/lib/py4j-0.10.7-src.zip:$PYTHONPATH

参考:

http://cn.voidcc.com/question/p-atfauqqw-be.html

https://blog.csdn.net/Apache_Jerry/article/details/108010320

 
原文地址:https://www.cnblogs.com/aaronhoo/p/15703936.html