Tag Archives: systemd

Linux下设置tomcat自启动

usr/lib/systemd/system

在当前目录下创建worker.service文件,内容如下:

[Unit]
Description=CPUS Transfer Worker
After=network.target remote-fs.target nss-lookup.target

[Service]
Type=forking
ExecStart=/root/bin/Transwork/startAll.sh

[Install]
WantedBy=multi-user.target
~
tomcat.service

[Unit]
Description=Tomcat
After=network.target remote-fs.target nss-lookup.target

[Service]
Type=forking
ExecStart=/usr/share/apache-tomcat-8.0.9/bin/startup.sh
ExecStop=/usr/share/apache-tomcat-8.0.9/bin/shutdown.sh

[Install]
WantedBy=multi-user.target
~
~
~
~
Refer:
CentOS7 增加tomcat 启动,停止,使用systemctl进行配置http://www.itnose.net/detail/6163208.html

Other:
查看全部服务命令:
systemctl list-unit-files –type service
查看服务
systemctl status name.service
启动服务
systemctl start name.service
停止服务
systemctl stop name.service
重启服务
systemctl restart name.service增加开机启动
systemctl enable name.service
删除开机启动
systemctl disable name.service
其中.service 可以省略。