编写服务开机自启动

2020-12-22 16:47:03 浏览数 (1)

启动脚本

代码语言:javascript复制
vi /usr/local/consul/start.sh

#!/bin/bash
/usr/local/bin/consul agent -config-dir=/etc/consul.d > /data/consul/consul.log

启动服务

代码语言:javascript复制
vi /usr/lib/systemd/system/consul.service

[Unit]
Description=consul
After=network.target

[Service]
ExecStart=/usr/local/consul/start.sh
KillSignal=SIGTERM

[Install]
WantedBy=multi-user.target

添加执行权限 chmod x /usr/local/consul/start.sh

启动 systemctl start consul

开机运行 systemctl enable consul

0 人点赞