Nathaniel's blog
Back to posts

Ways to create Systemd service

Nathaniel LinMarch 16, 20191 min read4 views
Ways to create Systemd service

创建一个文件 xxx.service,内容如下


[Unit] Description=服务描述

[Service] ExecStart=可执行文件地址

[Install] WantedBy=multi-user.target

  1. 扔进 /etc/systemd/system `

  2. 权限不足的话记得改权限


chmod u+x 服务对应的可执行文件

  1. 启动服务

sudo systemctl start xxx

  1. 开机时运行

sudo systemctl enable xxx

  1. 停止服务

sudo systemctl stop xxx

Share this post

Reactions