1、使用Jenkins执行远程shell脚本时,出现提示java: command not found;
原因是远程执行shell脚本时,不会自动加载环境变量,导致无法识别命令;
2、linux 中crontab 计划任务时,手动启动脚本正常,通过crontab调用时,无法正常执行。通过查看/var/spoon/mail/$user 下的日志文件或者/var/log/cron.log日志文件
第一种:
source ~/.bash_profile
第二种:
在脚本前面添加环境变量:
if [ -f ~/.bash_profile ];
then
. ~/.bash_profile
fi