【问题标题】:init.d fails with tomcatinit.d 因 tomcat 而失败
【发布时间】:2020-03-23 14:05:36
【问题描述】:

我在 ubuntu 服务器上使用 tomcat,并且我试图使用 monit 使其始终保持活动状态。 但我的问题是 monit 不起作用,因为

/etc/init.d/tomcat start

抛出此错误:

touch: cannot touch '/opt/tomcat/latest/logs/catalina.out': Permission denied
/opt/tomcat/latest/bin/catalina.sh: 467: /opt/tomcat/latest/bin/catalina.sh: cannot create /opt/tomcat/latest/logs/catalina.out: Permission denied

如果我将权限 777 授予 catalina.out,则 tomcat 将无法工作。但是如果我将权限更改为 755 我不能从 init.d 开始

我该如何解决?

这是我的“监控”代码:

check process tomcat with pidfile "/opt/tomcat/apache-tomcat-9.0.27/temp/tomcat.pid"
      start program = "/etc/init.d/tomcat start"
      stop program = "/etc/init.d/tomcat stop"
      if failed port 8080 for 5 cycles then restart

谢谢

【问题讨论】:

    标签: ubuntu tomcat server monit


    【解决方案1】:

    默认情况下,Monit 以 root 身份执行,但 Permission denied 消息可能表明您的 Monit 以 root 身份运行。

    我看到了两种解决方案:

    1. 以 root 身份执行 Monit
    2. 在您的初始化脚本之前添加/usr/bin/sudo,例如
    start program = "/usr/bin/sudo /etc/init.d/tomcat start"
    

    【讨论】:

      猜你喜欢
      • 2013-03-22
      • 1970-01-01
      • 1970-01-01
      • 2018-02-16
      • 2012-10-03
      • 2014-07-16
      • 2021-11-23
      • 2018-10-04
      • 2014-05-12
      相关资源
      最近更新 更多