CentOS
Tomcat
systemd

tomcat をsystemdに登録したらエラーでた


systemdに登録

自分で配置したtomcatをsystemdに登録する方法は以下の人たちが丁寧に解説してくれてます。

https://qiita.com/nyao/items/8ad51a56638e646b2ec1

https://qiita.com/ariaki/items/6fafac7d89ea14b12203


systemctl start tomcat.serviceが動かない

statusを見ると

[root@Server bin]# systemctl status tomcat.service

● tomcat.service - Apache Tomcat Servlet Container
Loaded: loaded (/etc/systemd/system/tomcat.service; enabled; vendor preset: disabled)
Active: failed (Result: exit-code) since 木 2018-11-08 23:00:37 JST; 38s ago
Process: 67018 ExecStop=/apache-tomcat/bin/shutdown.sh (code=exited, status=203/EXEC)
Process: 67016 ExecStart=/apache-tomcat/bin/startup.sh (code=exited, status=203/EXEC)
Main PID: 67016 (code=exited, status=203/EXEC)

11月 08 23:00:37 Server systemd[1]: Started Apache Tomcat Servlet Container.
11月 08 23:00:37 Server systemd[1]: Starting Apache Tomcat Servlet Container...
11月 08 23:00:37 Server systemd[1]: tomcat.service: main process exited, code=exited, status=203/EXEC
11月 08 23:00:37 Server systemd[1]: tomcat.service: control process exited, code=exited status=203
11月 08 23:00:37 Server systemd[1]: Unit tomcat.service entered failed state.
11月 08 23:00:37 Server systemd[1]: tomcat.service failed.

赤や黄色の文字で文句を言われました。


ログは/var/log/messageに!

Nov  8 22:44:51 Server systemd: Started Apache Tomcat Servlet Container.

Nov 8 22:44:51 Server systemd: Starting Apache Tomcat Servlet Container...
Nov 8 22:44:51 Server systemd: Failed at step EXEC spawning /apache-tomcat/bin/startup.sh: Permission denied
Nov 8 22:44:51 Server systemd: tomcat.service: main process exited, code=exited, status=203/EXEC
Nov 8 22:44:51 Server systemd: Failed at step EXEC spawning /apache-tomcat/bin/shutdown.sh: Permission denied
Nov 8 22:44:51 Server systemd: tomcat.service: control process exited, code=exited status=203
Nov 8 22:44:51 Server systemd: Unit tomcat.service entered failed state.
Nov 8 22:44:51 Server systemd: tomcat.service failed.

ただのPermission deniedでした。

startup.shとshutdown.shに実行権限与えたらちゃんと動きました!!