问题

在一个Linux服务器上有shell 脚本如下:

nohup java -jar test.jar >> ./nohup.out 2>&1 &

直接执行脚本 sh start.sh 是没有问题的

但是在另一个服务器上,执行这个服务器上的脚本,就会出现

nohup: 无法运行命令"java": 没有那个文件或目录 

 

解决办法

无法识别java命令,填写全路径就可以

nohup /usr/java/jdk1.8.0_131/bin/java -jar test.jar >> ./nohup.out 2>&1 &

 

用了下面的方法无效
1、source /etc/profilesource /root/.bash_profile
2、shell脚本头添加 #!/bin/bash

 

原创文章,欢迎转载,转载请注明出处!

相关文章:

  • 2022-12-23
  • 2022-03-08
  • 2022-12-23
  • 2022-12-23
  • 2022-03-11
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-02-14
  • 2022-12-23
  • 2022-12-23
  • 2021-04-07
  • 2021-10-23
相关资源
相似解决方案