tomcat自启动脚本
时间: 2023-10-23 08:48:43 浏览: 94
可以在Linux系统中使用systemctl命令来实现tomcat的自启动,具体命令可参考以下代码:
1. 编写一个tomcat.service文件
sudo vi /etc/systemd/system/tomcat.service
2. 将以下内容复制到tomcat.service文件中
[Unit]
Description=Apache Tomcat Web Application Container
After=syslog.target network.target
[Service]
Type=forking
Environment=JAVA_HOME=/usr/local/jdk1.8.0_202
Environment=CATALINA_PID=/opt/tomcat/tomcat.pid
Environment=CATALINA_HOME=/opt/tomcat
Environment=CATALINA_BASE=/opt/tomcat
Environment='CATALINA_OPTS=-Xms512M -Xmx1024M -server -XX:+UseParallelGC'
Environment='JAVA_OPTS=-Djava.awt.headless=true -Djava.security.egd=file:/dev/./urandom'
ExecStart=/opt/tomcat/bin/startup.sh
ExecStop=/opt/tomcat/bin/shutdown.sh
User=root
Group=root
UMask=0007
RestartSec=10
Restart=always
[Install]
WantedBy=multi-user.target
3. 保存文件并退出
4. 重新加载systemd配置文件
sudo systemctl daemon-reload
5. 启动tomcat服务
sudo systemctl start tomcat
6. 设置tomcat服务自启动
sudo systemctl enable tomcat
以上为linux中tomcat自启动脚本的操作方式,希望对您有帮助。
阅读全文