新建umpserver.service
[Unit]
Description=UMPServer
After=syslog.target network.target remote-fs.target nss-lookup.target
[Service]
Type=forking
ExecStart=/home/work/start.sh
ExecStop=/home/work/stop.sh
PrivateTmp=true
[Install]
WantedBy=multi-user.target
添加可执行权限
chmod +x umpserver.service
把文件复制到/lib/systemd/system/目录下
cp umpserver.service /lib/systemd/system
添加开机启动
systemctl enable umpserver.service
移除开机启动
systemctl disable umpserver.service
启动或停止umpserver命令
systemctl stop umpserver.service
该指令,执行umpserver.service中,ExecStop属性中指定的脚本,如下图所示
启动umpserver命令,执行/home/work/start.sh脚本
systemctl start umpserver.service
重启命令:
systemctl restart umpserver.service
相当于,先执行umpserver的stop命令,在执行start命令。
查看是否开机启动命令:
systemctl list-unit-files |grep umpserver
enabled表示开机启动;disable表示开机不启用。