子嘉的博客 子嘉的博客
首页
bic-bic
技术
关于
收藏
  • 分类
  • 标签
  • 归档
GitHub (opens new window)

高子嘉

没有比脚更长的路,没有比人更高的山
首页
bic-bic
技术
关于
收藏
  • 分类
  • 标签
  • 归档
GitHub (opens new window)
  • 技术文档

  • GitHub技巧

  • 博客搭建

  • 服务端

  • distributed

  • golang

  • db

  • docker

  • linux

    • directory
    • directory
      • linux 服务
      • 服务定义
      • 命令
    • user
    • shell

  • 技术
  • linux
子嘉
2023-11-28
目录

directory

# linux 服务

  1. 服务通常使用下面命令启动
systemctl start <服务名>
1
  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

__ 注意下可执行文件是否有权限执行 __

# 命令

  1. 启用服务
systemctl enable demo
1
  1. 重载配置
systemctl daemon-reload
1
  1. 启动和重启服务
systemctl start demo
systemctl restart demo
1
2
  1. 服务状态查看
systemctl status demo
1

注意:普通用户不具有 systemctl 管理的 service 执行权限,可通过下面配置解决,或参照博客 (opens new window)

编辑 (opens new window)
上次更新: 2025/03/08, 12:51:50
directory
user

← directory user→

最近更新
01
mongodb restore
03-06
02
pytesseract
02-28
03
consul
02-24
更多文章>
Theme by Vdoing | Copyright © 2022-2025 子嘉 | MIT License
  • 跟随系统
  • 浅色模式
  • 深色模式
  • 阅读模式