directory
# linux 服务
- 服务通常使用下面命令启动
systemctl start <服务名>
1
- 服务状态查看
systenctl status <服务名>
1
# 服务定义
示例文件 /etc/systemd/system/demo.service
[Unit]
Description=Demo Service
After=network.target
[Service]
Type=simple
User=root
Restart=always
RestartSec=5s
ExecStart=/root/workspace/gh/pilot-go/pilot
LimitNOFILE=1048576
[Install]
WantedBy=multi-user.target
1
2
3
4
5
6
7
8
9
10
11
12
13
14
2
3
4
5
6
7
8
9
10
11
12
13
14
__ 注意下可执行文件是否有权限执行 __
# 命令
- 启用服务
systemctl enable demo
1
- 重载配置
systemctl daemon-reload
1
- 启动和重启服务
systemctl start demo
systemctl restart demo
1
2
2
- 服务状态查看
systemctl status demo
1
注意:普通用户不具有 systemctl 管理的 service 执行权限,可通过下面配置解决,或参照博客 (opens new window)
编辑 (opens new window)
上次更新: 2025/03/08, 12:51:50