linux service文件创建

service 模板

1
wget https://dl.halo.run/config/halo.service -O /etc/systemd/system/halo.service

重新加载 systemd

1
systemctl daemon-reload

运行服务

1
systemctl start halo

在系统启动时启动服务

1
systemctl enable halo

您可以查看服务日志检查启动状态

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
启动服务:systemctl start vsftpd.service

关闭服务:systemctl stop vsftpd.service

重启服务:systemctl restart vsftpd.service

显示服务的状态:systemctl status vsftpd.service

在开机时启用服务:systemctl enable vsftpd.service

在开机时禁用服务:systemctl disable vsftpd.service

查看服务是否开机启动:systemctl is-enabled vsftpd.service

查看已启动的服务列表:systemctl list-unit-files|grep enabled

查看启动失败的服务列表:systemctl --failed