小记---------手动执行脚本正常执行,使用crontab定时执行时 不执行

可能出现的原因就是因为crontab不会从用户的/etc/profile文件中读取环境变量,所以就出现 使用定时crontab执行时 无法执行 抛错

所以在使用crontab 定时执行脚本时  在脚本中尽量使用绝对路径,除去全局变量以外

解决方法:

1.

 

 直接把/etc/profile文件中配置的spark的环境变量写到脚本的开头,使它在执行脚本之前先加载spark的环境变量即可

2.直接在脚本中添加即可

#!/bin/bash
#此处添加如下
./etc/profile

 num_executors=3
 executor_memory=2g
 driver_memory=2g
 executor_cores=2
 realtime_queue=root
 # backpressure
 receiver_max_rate=100
 receiver_initial_rate=30
 my_job_name="cron"
 main_class="com.df.Crontab_reservation"

 spark-submit --master yarn --deploy-mode cluster \
 --name ${my_job_name} \
 --class ${main_class} \

 

posted @ 2019-10-10 15:06  于二黑  阅读(533)  评论(0编辑  收藏  举报