Ubuntu下设置Tomcat开机自动启动
3.1 在/etc/init.d目录下新建tomcat文件
sudo cd /etc/init.d
sudo vi tomcat
3.2 添加启动、关闭、重启的shell脚本
1 | #!/bin/sh |
3.3 保存退出,授予tomcat文件执行权限
chmod +x tomcat
3.4 使tomcat服务生效,并使能开机自启动,然后reboot重启,即可Tomcat开机自启动生效.
sudo systemctl daemon-reload #对于新创建的unit文件或修改了的unit文件,要通知systemd重载此配置文件;
sudo systemctl enable tomcat #使能开机自启动
sudo reboot
3.5 重启后,执行systemctl status tomcat看看tomcat服务的状态。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
root@localhost:~# systemctl status tomcat
● tomcat.service
Loaded: loaded (/etc/init.d/tomcat; bad; vendor preset: enabled)
Active: active (running) since Thu 2018-08-23 21:54:25 PDT; 44s ago
Docs: man:systemd-sysv-generator(8)
Process: 811 ExecStart=/etc/init.d/tomcat start (code=exited, status=0/SUCCESS)
CGroup: /system.slice/tomcat.service
└─832 /usr/lib/jvm/java-8-openjdk-amd64/bin/java -Djava.util.logging.config.file=/home/localhost/apache-tomcat-9.0.11/conf/logging.propertie
Aug 23 21:54:24 localhost systemd[1]: Starting tomcat.service...
Aug 23 21:54:25 localhost tomcat[811]: $Starting Tomcat
Aug 23 21:54:25 localhost tomcat[811]: Tomcat started.
Aug 23 21:54:25 localhost tomcat[811]: OK
Aug 23 21:54:25 localhost systemd[1]: Started tomcat.service.
1 | root@localhost:~# systemctl status tomcat |
作者:相信美好的事情将会发生
来源:CSDN
原文:https://blog.csdn.net/bbaaEE/article/details/82015155
版权声明:本文为博主原创文章,转载请附上博文链接!