V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
Distributions
Ubuntu
Fedora
CentOS
中文资源站
网易开源镜像站
yifanes
V2EX  ›  Linux

systemctl disable xxx 之后不起作用

  •  
  •   yifanes · 2020-08-08 17:13:29 +08:00 · 3781 次点击
    这是一个创建于 1350 天前的主题,其中的信息可能已经有所发展或是发生改变。

    生产环境下, 一些 systemd 配置的服务不能开机自启动, 所以需要 disable 掉,但是问题是 disable 之后, systemctl is-enabled xxx, 结果还是 enable

    1.文件在 /etc/systemd/system/xxx.service

    2.文件权限正常(因为同权线的可以 disable)

    3.disable 之后 /etc/systemd/system/multi-user.target.wants/里面的软链确实被删

    4.systemctl cat xxx

    [Unit]
    Description=xxx service
    After=network.target
    
    [Service]
    Group=www
    User=www
    Type=simple
    Restart=always
    RestartSec=5
    ExecStart=/home/www/bin/xxx
    WorkingDirectory=/home/www/bin
    
    [Install]
    WantedBy=multi-user.target
    Alias=xxx
    
    11 条回复    2020-08-09 01:21:11 +08:00
    JackieMe
        1
    JackieMe  
       2020-08-08 17:27:18 +08:00 via Android
    systemctl mask 试试
    yifanes
        2
    yifanes  
    OP
       2020-08-08 17:31:17 +08:00
    @JackieMe systemctl mask xxx 提示这个: Failed to execute operation: Invalid argument
    choury
        3
    choury  
       2020-08-08 19:23:27 +08:00 via Android
    service 文件怎么放 /etc 目录呢,不是 /lib 下面吗,然后启用才链接过来
    wwqgtxx
        4
    wwqgtxx  
       2020-08-08 19:36:50 +08:00 via iPhone   ❤️ 1
    @choury 用户自定义的 service 本来就该在 /etc 下,并没有问题
    Cooky
        5
    Cooky  
       2020-08-08 19:39:51 +08:00 via Android
    是 socket 吧,有的服务有 service 还有个 socket
    ClericPy
        6
    ClericPy  
       2020-08-08 19:51:30 +08:00
    一直用的 systemctl --user 倒是没遇到过, 话说不用 --user 的 config 有什么优缺点么
    msg7086
        7
    msg7086  
       2020-08-08 20:08:48 +08:00 via Android
    @wwqgtxx enable 是在 etc 下做 lib 的软链接吧,那如果本来就在 etc 下,disable 是要把文件原地删了么…
    wwqgtxx
        8
    wwqgtxx  
       2020-08-08 21:27:53 +08:00
    @msg7086 enable 是在 /etc/systemd/system/multi-user.target.wants/里面新建软链,但是 /etc/systemd/system/下是可以直接放用户自定义的 service 文件的(实际上很多位置都可以放,可以参考这个文档 http://www.jinbuguo.com/systemd/systemd.unit.html
    hijoker
        9
    hijoker  
       2020-08-08 22:50:10 +08:00
    journalctl -xe 报啥?
    yanqiyu
        10
    yanqiyu  
       2020-08-09 01:18:10 +08:00 via Android   ❤️ 1
    @ClericPy user 的 unit 只适用于 user 会话,默认是随登录运行,所有会话注销退出(开启 linger 模式后和系统 instance 行为类似)
    yanqiyu
        11
    yanqiyu  
       2020-08-09 01:21:11 +08:00 via Android
    https://www.freedesktop.org/software/systemd/man/systemctl.html

    关于 is-enabled 的解释
    > Enabled via .wants/, .requires/ or Alias= symlinks (permanently in /etc/systemd/system/, or transiently in /run/systemd/system/).

    要不检查一下是不是 Alias 搞事情了
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   1135 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 24ms · UTC 23:40 · PVG 07:40 · LAX 16:40 · JFK 19:40
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.