mos*_*eta 5 debian systemd systemctl
我有一个一次性服务,我想在 Networking.service 开始运行之前完成运行(而不仅仅是启动)。我阅读了手册页并认为这就足够了
[Unit]
Description=mypre networking service
Before=networking.service
Requires=networking.service
[Service]
Type=oneshot
ExecStart=/usr/local/bin/configuremodem.bash
TimeoutStartSec=1min
[Install]
WantedBy=multi-user.target network-online.target
Run Code Online (Sandbox Code Playgroud)
该服务大约需要 20 秒,当我登录系统并检查状态时,它仍在运行。使用systemd-analyze检查关键路径后,我可以看到该服务是在networking.service之前启动的,但systemd没有等待它完成。我认为,这就是阅读手册页的全部要点。我也刚刚通过改变达到了我想要的结果:
ExecStartPre=/usr/local/bin/configuremodem.bash
ExecStart=/bin/echo done
Run Code Online (Sandbox Code Playgroud)
在我读到 ExecStart 在 Pre 退出之前不会被执行。有更好的方法吗?
谢谢!
| 归档时间: |
|
| 查看次数: |
414 次 |
| 最近记录: |