nohup: failed to run command `java': No such file or directory解决

版权声明:转载请标明出处 https://blog.csdn.net/u013189824/article/details/85338221

程序里远程执行shell命令(nohup java -jar ...)的执行,后台日志报错如下:

nohup: failed to run command `java': No such file or directory

原因:一般来说这个报错说明服务器执行不了"java"这个命令

解决:

1、检查执行该shell的服务器有没有装jdk

2、检查执行该shell的服务器的环境变量有没有将JAVA_HOME/bin加入(目的是可以在linux任意位置执行java命令)

-----------------------------------------------------------------------------------------------------------------------------------------

坑的是:我检查了linux环境,java安装正确,环境变量也加了,把shell命令拿到远程服务器用户下任意目录执行也正常!!但是通过程序远程调用该shell命令还是报如上错误

无奈我在程序里执行 nohup java -jar ... 命令前,先执行了一把 source /etc/profile , 执行shell命令如下:

source /etc/profile; nohup java -jar ...

然后成功测试通过!!!

猜你喜欢

转载自blog.csdn.net/u013189824/article/details/85338221