-
需求背景
Linux重启后要手动执行"startup.sh"启动Tomcat,比较麻烦,想要Linux开机启动Tomcat。
-
开机启动
#---------------------------------------------------------- sudo tee /usr/bin/tomcat.sh <<-'EOF' #! /bin/bash nohup /opt/tomcat/bin/startup.sh > /opt/tomcat/nohup.log & EOF chmod +x /usr/bin/tomcat.sh #---------------------------------------------------------- sudo tee /etc/systemd/system/tomcat.service <<-'EOF' [Unit] Description=tomcat After=syslog.target network.target [Service] Environment="JAVA_HOME=/opt/jdk" Type=oneshot RemainAfterExit=yes ExecStart=/usr/bin/tomcat.sh [Install] WantedBy=multi-user.target EOF #---------------------------------------------------------- systemctl enable tomcat #---------------------------------------------------------- # 启动tomcat systemctl start tomcat # 停止tomcat systemctl stop tomcat # 重启tomcat systemctl restart tomcat # 查看tomcat状态 systemctl status tomcat
-
注意事项
#---------------------------------------------------------- "tomcat.service"不添加Environment="JAVA_HOME=/opt/jdk"报错如下 #---------------------------------------------------------- Neither the JAVA_HOME nor the JRE_HOME environment variable is defined At least one of these environment variable is needed to run this program #---------------------------------------------------------- 解决方法:"startup.sh"首行添加"export JAVA_HOME=/opt/jdk"可解决 #----------------------------------------------------------
Linux开机启动Tomcat
童心同萌2023-08-31 10:56
相关推荐
斯普信专业组1 分钟前
Ceph异地数据同步之-RBD异地同步复制(下)counsellor5 分钟前
CentOS 7安装hyperscan电星托马斯8 分钟前
Linux系统CentOS 6.3安装图文详解啞謎专家11 分钟前
CentOS中挂载新盘LVM指南:轻松扩展存储空间,解决磁盘容量不足问题s_little_monster23 分钟前
【Linux】进程信号的捕捉处理一大Cpp34 分钟前
Ubuntu与本地用户交流是两种小方法小王不会写code38 分钟前
CentOS 7 镜像源失效解决方案(2025年)zyplanke41 分钟前
CentOS Linux升级内核kernel方法go_bai1 小时前
Linux环境基础开发工具——(2)vimWannaRunning1 小时前
浅谈Tomcat数据源连接池