linux(ubuntu)使用systemctl添加自启动

Posted by baicai on December 13, 2018

新建配置文件

sudo vim /lib/systemd/system/abc.service 

abc.service里写入以下内容

[Unit]
Description=abc service
After=network.target syslog.target
Wants=network.target

[Service]
Type=simple
#启动服务的命令(此处写你的abc的实际安装目录)
ExecStart=/your/path/abc -a your -b params

[Install]
WantedBy=multi-user.target


启动abc 

sudo systemctl start abc

打开自启动 

sudo systemctl enable abc

重启应用

sudo systemctl restart abc

停止应用

sudo systemctl stop abc

查看应用的日志

sudo systemctl status abc