Distributions
› Ubuntu
› Fedora
› CentOS
中文资源站
› 网易开源镜像站
Oathbinder
V2EX  ›  Linux

如何让 Linux 在用户空间启动早期执行一个脚本

  •  
  •   Oathbinder · Jun 22, 2019 · 4135 views
    This topic created in 2692 days ago, the information mentioned may be changed or developed.

    目前有 A.service:

    type=oneshot
    Before=emergency.service sysinit.target
    ExecStart=/usr/bin/foo
    

    A 在系统启动早期被调用并且只运行一次不 fork 到后台,如果想让 B.service 也只运行一次不 fork 到后台,而且要确保一定要在 A 启动前就执行完毕,应该如何设置 B.service 的参数并且不修改 A.service ?或者说能不能让 B 在系统启动更早期运行,只要能保证 B 执行完才去启动其他 service。B.service 的作用是备份一个特定文件所以只涉及到了 /的读写,不会用到网络等服务,所以越早运行 B 越好

    2 replies  •  2019-06-22 14:50:23 +08:00
    Earl
    Earl
    Jun 22, 2019
    1
    如果 B 只需要在 A 前面,那么在 B 里面加上 Before 命令就好了。
    liangzi
    liangzi
    Jun 22, 2019 via Android
    2
    有的发行版 开启默认有静态服务 只在开机启动 比如 after.local 对应的服务
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   1387 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 28ms · UTC 20:55 · PVG 04:55 · LAX 12:55 · JFK 15:55
    ♥ Do have faith in what you're doing.