使用systemctl添加自定义系统服务
一、内容
[Unit]
Description=openfire
After=network.target
[Service]
Type=forking
ExecStart=/etc/init.d/openfire start
ExecStop=/etc/init.d/openfire stop
#RemainAfterExit=yes
[Install]
WantedBy=multi-user.target
说明:
[Unit]
主要是对这个服务的说明
Description用于描述服务
After用于描述服务类别。
[Service]
服务的一些具体运行参数的设置
Type=forking是后台运行的形式
ExecStart服务的运行命令
ExecStop为停止命令
RemainAfterExit 如果设置这个选择为真,服务会被认为是在激活状态,即使所以的进程已经退出,默认的值为假,这个选项只有在Type=oneshot时需要被配置。
[Install]
服务安装的相关设置,可设置为多用户的
二、添加开机启动
systemctl enable openfire