LSB 确认启动脚本不会在 ubuntu 上启动 apache tomcat

LSB 确认启动脚本不会在 ubuntu 上启动 apache tomcat

我想在启动时自动启动我的 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

我在这里遗漏了什么?

答案1

这些

uname:未找到
dirname:未找到

表明您缺少正确的路径。

尝试将启动脚本中的 PATH 行更改为: PATH=/bin:/usr/bin:/sbin:/usr/sbin:/opt/jdk1.7.0_21:/opt/apache-tomcat-7.0.39

答案2

这就是问题所在

PATH=/opt/jdk1.7.0_21:/opt/apache-tomcat-7.0.39

你忘了将 $PATH 附加到那里..它必须是

PATH=/opt/jdk1.7.0_21:/opt/apache-tomcat-7.0.39:$PATH

相关内容