背景: 在前面两中自启未生效时,寻找第三种方法,创建linux服务,然后让服务自启,方法如下:
在/etc/systemd/system/使用service进行重启
1、创建对应的服务名 ge: ghp2-spumes-inspection.service
2、编写自启服务
[Unit] Description=ghp2-spumes-inspection After=network.target [Service] Type=simple ExecStart=/opt/toplinker-python/ghp2-spumes-inspection/python3/bin/python3.8 /opt/toplinker-python/ghp2-spumes-inspection/src8885/backend/main.py start ExecStop='ps -ef |grep ghp2-spumes-inspection |awk '{print $2}' | xargs kill -9 ' Restart=on-failure RestartSec=3 User=root Group=root [Install] WantedBy=multi-user.target
3、将上面服务赋予执行权限
chomd 777 test.service 或者(chomd +x test.service)
4、然后加载上面的服务
systemctl daemon-reload
5、启动服务
systemctl start ghp2-spumes-inspection.service
6、查看状态
systemctl status ghp2-spumes-inspection.service
标签:ghp2,服务,spumes,service,自启,linux,inspection From: https://www.cnblogs.com/lovekt/p/16851096.html