Linux运维-陈雷雷


tomcat启动停止脚本

admin 2019-12-29 92浏览 1条评论
首页/正文
分享到: / / / /

tomcat启动停止脚本:

vim /usr/lib/systemd/system/tomcat.service
[Unit]
Description=Tomcat
After=network.target

[Service]
Type=forking

Environment="JAVA_HOME=/application/jdk"

ExecStart=/application/tomcat/bin/startup.sh
ExecStop=/application/tomcat/bin/shutdown.sh

[Install]
WantedBy=multi-user.target

添加执行权限

chmod 600 /usr/lib/systemd/system/tomcat.service
systemctl daemon-reload 

测试启动停止重启:

启动:
systemctl start tomcat.service 

查看状态:

[root@leilei bin]# systemctl status tomcat.service 
● tomcat.service - Tomcat
   Loaded: loaded (/usr/lib/systemd/system/tomcat.service; disabled; vendor preset: disabled)
   Active: active (running) since Sun 2019-12-29 17:01:12 CST; 58s ago
  Process: 4060 ExecStop=/application/tomcat/bin/shutdown.sh (code=exited, status=0/SUCCESS)
  Process: 4218 ExecStart=/application/tomcat/bin/startup.sh (code=exited, status=0/SUCCESS)
 Main PID: 4227 (java)
   CGroup: /system.slice/tomcat.service
           └─4227 /application/jdk/bin/java -Djava.util.logging.config.file=/application/tomcat/conf/logging.properties 

Dec 29 17:01:12 leilei systemd[1]: Starting Tomcat...
Dec 29 17:01:12 leilei systemd[1]: Started Tomcat.
Dec 29 17:01:12 leilei startup.sh[4218]: Tomcat started.

#停止: [root@leilei bin]# systemctl stop tomcat.service

#查看状态:

[root@leilei bin]# systemctl status tomcat.service 
● tomcat.service - Tomcat
   Loaded: loaded (/usr/lib/systemd/system/tomcat.service; disabled; vendor preset: disabled)
   Active: failed (Result: signal) since Sun 2019-12-29 17:03:23 CST; 5s ago
  Process: 4637 ExecStop=/application/tomcat/bin/shutdown.sh (code=exited, status=0/SUCCESS)
  Process: 4218 ExecStart=/application/tomcat/bin/startup.sh (code=exited, status=0/SUCCESS)
 Main PID: 4227 (code=killed, signal=KILL)

Dec 29 17:01:12 leilei startup.sh[4218]: Tomcat started.
Dec 29 17:03:17 leilei systemd[1]: Stopping Tomcat...
Dec 29 17:03:22 leilei shutdown.sh[4637]: Tomcat did not stop in time.
Dec 29 17:03:22 leilei shutdown.sh[4637]: To aid diagnostics a thread dump has been written to standard out
Dec 29 17:03:22 leilei shutdown.sh[4637]: Killing Tomcat with the PID: 4227
Dec 29 17:03:22 leilei systemd[1]: tomcat.service: main process exited, code=killed, status=9/KILL
Dec 29 17:03:23 leilei shutdown.sh[4637]: The Tomcat process has been killed.
Dec 29 17:03:23 leilei systemd[1]: Stopped Tomcat.
Dec 29 17:03:23 leilei systemd[1]: Unit tomcat.service entered failed state.
Dec 29 17:03:23 leilei systemd[1]: tomcat.service failed.

重新启动:

[root@leilei bin]# systemctl restart tomcat.service

状态:

[root@leilei bin]# systemctl status tomcat.service 
● tomcat.service - Tomcat
   Loaded: loaded (/usr/lib/systemd/system/tomcat.service; disabled; vendor preset: disabled)
   Active: active (running) since Sun 2019-12-29 17:04:16 CST; 2s ago
  Process: 4637 ExecStop=/application/tomcat/bin/shutdown.sh (code=exited, status=0/SUCCESS)
  Process: 4854 ExecStart=/application/tomcat/bin/startup.sh (code=exited, status=0/SUCCESS)
 Main PID: 4863 (java)
   CGroup: /system.slice/tomcat.service
           └─4863 /application/jdk/bin/java -Djava.util.logging.config.file=/application/tomcat/conf

Dec 29 17:04:16 leilei systemd[1]: Starting Tomcat...
Dec 29 17:04:16 leilei systemd[1]: Started Tomcat.
Dec 29 17:04:16 leilei startup.sh[4854]: Tomcat started.
最后修改:2019-12-29 17:07:15 © 著作权归作者所有
如果觉得我的文章对你有用,请随意赞赏
扫一扫支付

上一篇

发表评论

评论列表

匿名用户 2020-01-08 11:41:49
<p>这个可以服务可以跟随服务自动启动吗?</p><p><span>[Service]</span></p><span class="hljs-attr">Type</span><span>=forking&nbsp; &nbsp;这个参数是什么意思? 跟其他人不一样</span><div><span><br></span></div>
回复

博客信息

  • 文章数目 102
  • 标签数目 298
  • 运行天数
  • 最后活动

广告



文章目录