我使用CentOs 7.5.1804,服务有问题。当我用systemctl启动我的服务时,它会在消息中失败。
which: no java in (/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin)
Java not found!在错误消息之后,我执行了一个
然后它又回来了
which: no java in (/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin)
Java not found!但是,当我以用户应用程序的身份登录到系统时,我会收到java -version的反馈。
java version "1.8.0_161"
Java(TM) SE Runtime Environment (build 1.8.0_161-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.161-b12, mixed mode)下面是我的服务片段,位于/etc/systemd/system中
[Service]
Type=forking
User=app
Group=app
ExecStart=/opt/div/ui/bin/service.sh -s start -t myserver
ExecStop=/opt/div/ui/bin/service.sh -s stop -t myserver
SuccessExitStatus=143
TimeoutStartSec=0
TimeoutStopSec=240
#install
[Install]
WantedBy=multi-user.target我错过了什么?有什么建议吗?
发布于 2018-08-21 16:36:46
Systemd使用固定的搜索路径,并强烈鼓励对可执行文件使用完全路径。
来自systemd.exec手册页:
Systemd uses a fixed value of
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin.最好的解决方案是在service.sh脚本中使用java可执行文件的完整路径。
https://serverfault.com/questions/927367
复制相似问题