-
需求背景
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
相关推荐
watermelonoops18 分钟前
Deepin和Windows传文件(Xftp,WinSCP)疯狂飙车的蜗牛1 小时前
从零玩转CanMV-K230(4)-小核Linux驱动开发参考远游客07133 小时前
centos stream 8下载安装遇到的坑马甲是掉不了一点的<.<3 小时前
本地电脑使用命令行上传文件至远程服务器jingyu飞鸟3 小时前
centos-stream9系统安装docker超爱吃士力架4 小时前
邀请逻辑cominglately6 小时前
centos单机部署seata魏 无羡6 小时前
linux CentOS系统上卸载dockerCircleMouse7 小时前
Centos7, 使用yum工具,出现 Could not resolve host: mirrorlist.centos.org木子Linux7 小时前
【Linux打怪升级记 | 问题01】安装Linux系统忘记设置时区怎么办?3个方法教你回到东八区