Linux服务Service

Linux服务Service

实例

[Unit]
Description=baoshen bridge water-level service
After=network.target
StartLimitIntervalSec=0

[Service]
Type=simple
User=amax
Group=amax
Restart=always
RestartSec=1
WorkingDirectory=/home/amax/anyvision-v2/config-baoshen/config-water-level
ExecStart=/home/amax/anyvision-v2/config-baoshen/config-water-level/run.sh

[Install]
WantedBy=multi-user.target

将写好的服务放在/etc/systemd/system/路径下

使用方法

加载,启动服务

  • 重新加载守护进程
systemctl daemon-reload
  • 设置服务开机自启动
systemctl enable ohasd.service
  • 手工启动服务
systemctl start ohasd.service
posted @ 2022-11-11 13:06  nanmi  阅读(13)  评论(0编辑  收藏  举报