Linux tomcat加入Systemctl服务,开机自启动
tomcat请自信配置,下面是将tomcat加入Systemctl服务中方法;
一、在tomcat bin目录下创建setenv.sh文件
二、在setenv.sh文件中添加以下内容
注:tomcat-zxxfht.pid 文件名自定义,tomcat启动是会zi自动创建tomcat-zxxfht.pid文件且与bin目录同级,也可自定义文件生成路径
三、在/usr/lib/systemd/system目录下创建 xxx.service文件
四、在xxx.service文件里面添加
注:Description 服务名称,自定义一个
PIDFile :pid文件地址,也就是setenv.sh文件里面配置生成的文件地址
ExecStart:tomcat启动wenj文件地址
这样就将tomcat服务配置到Systemctl服务中了,如果需要配置多个tomcat,配置多个服务就可以了。
Systemctl常用命令:
修改
xxx.service文件后刷新服务
systemctl daemon-reload启动某服务
systemctl start tomcat.service
停止某服务
systemctl stop tomcat.service
重启某服务
systemctl restart tomcat.service
使某服务自动启动(如tomcat服务)
systemctl enable tomcat.service
使某服务不自动启动
systemctl disable tomcat.service
检查服务状态
systemctl status tomcat.service (服务详细信息)
systemctl is-active tomcat.service(仅显示是否Active)
显示所有已启动的服务
systemctl list-units --type=service