我想在启动时自动启动我的tomcat服务器。 因此,我从网上检索了一个简单的LSB符合脚本,并将其修改为我的需要。 这是脚本:
# Provide logging functions like log_success_msg, log_failure_msg and log_warning_msg . /lib/lsb/init-functions [ -f /etc/default/rcS ] && . /etc/default/rcS PATH=/opt/jdk1.7.0_21:/opt/apache-tomcat-7.0.39 case "$1" in start) /opt/apache-tomcat-7.0.39/bin/startup.sh ;; stop) /opt/apache-tomcat-7.0.39/bin/shutdown.sh ;; restart|force-reload) ;; status) ;; *) log_failure_msg "Usage: {start|stop|restart|force-reload|status}" exit 1 esac exit 0
现在,我将它复制到/etc/init.d并在其上应用了一个“chmod + x tomcat”。 然后我试图运行它
/etc/init.d # ./tomcat start /opt/apache-tomcat-7.0.39/bin/startup.sh: 1: /opt/apache-tomcat-7.0.39/bin/startup.sh: uname: not found /opt/apache-tomcat-7.0.39/bin/startup.sh: 1: /opt/apache-tomcat-7.0.39/bin/startup.sh: dirname: not found Cannot find /catalina.sh The file is absent or does not have execute permission This file is needed to run this program
我在这里错过了什么?
这些
uname:找不到
dirname:找不到
表明你错过了一个合适的PATH。
尝试将启动脚本中的PATH行更改为: PATH=/bin:/usr/bin:/sbin:/usr/sbin:/opt/jdk1.7.0_21:/opt/apache-tomcat-7.0.39
这是问题
PATH = /select/ jdk1.7.0_21:/opt/apache-tomcat-7.0.39
你忘了附加$ PATH的..它必须是
PATH = /select/ jdk1.7.0_21:/opt/apache-tomcat-7.0.39:$ PATH