linux 设置tomcat开机启动

1、设置Tomcat开机自启

在/etc/systemd/system路径下创建tomcat.service文件

命令:vim /etc/systemd/system/tomcat.service

将以下内容添加到omcat.service中:

bash 复制代码
[Unit]
Description=tomcat-server
After=network.target

[Service]
Type=forking

Environment="JAVA_HOME=/opt/jdk1.6.0_45"   #jdk安装目录

ExecStart=/home/apache-tomcat-7.0.100/bin/startup.sh  #tomcat安装目录
ExecStop=/home/apache-tomcat-7.0.100/bin/shutdown.sh  #tomcat安装目录
ExecReload=/bin/kill -s HUP $MAINPID

User=root
Group=root

[Install]
WantedBy=multi-user.target

2、重新加载 systemd 的配置

bash 复制代码
systemctl daemon-reload

3、启用Tomcat服务

bash 复制代码
systemctl enable tomcat.service

4、使用以下命令启动 Tomcat 服务,测试之前记得停止运行的tomcat

bash 复制代码
systemctl start tomcat.service

5、查看启动状态,如下图:

bash 复制代码
 systemctl status tomcat.service
相关推荐
tntxia15 小时前
linux curl命令详解_curl详解
linux
扛枪的书生17 小时前
Linux 网络管理器用法速查
linux
SkyWalking中文站19 小时前
认识 Horizon UI · 1/17:SkyWalking 新一代可观测性控制台
运维·前端·监控
顺风尿一寸20 小时前
Java Socket 内核之旅:从 SocketChannel.read() 到 tcp_recvmsg 与 epoll 的完整调用链路
linux
雪梨酱QAQ1 天前
Kubeneters HA Cluster部署
运维
江华森1 天前
Spring Cloud 微服务全栈实战:从 Eureka 到 Docker Compose 一文贯通
运维
江华森1 天前
Matplotlib 数据绘图基础入门
运维
XIAOHEZIcode1 天前
Ubuntu 终端美化全栈指南:Bash 到 Kitty 踩坑实录
linux·ubuntu·命令行
江华森1 天前
NumPy 数值计算基础入门
运维
唐青枫1 天前
别再只会用 cron:Linux systemd Timer 定时任务实战详解
linux