systemd-让ss晚点启动

不知从什么时候开始,发现开机后ss总没有成功启动,每次开机后总要restart一下ss-libev的service才能上谷歌。
今天解决一下:

  1. 查看一下unit cat /usr/lib/systemd/system/[email protected]
    ```ini
    [Unit]
    Description=***-Libev Client Service
    After=network-online.target

    [Service]
    Type=simple
    User=nobody
    CapabilityBoundingSet=CAP_NET_BIND_SERVICE
    ExecStart=/usr/bin/ss-local -c /etc/shadowsocks/%i.json

    [Install]
    WantedBy=multi-user.target
    ```
  2. 打印以下启动顺序 systemd-analyze plot > aaa.svg


    可以发现ss的服务紧跟着 network-online.target 就启动了,无线网卡的启动在它之后(并不知道这个顺序是否重要)。
  3. 修改一下unit
    保险起见,把它改到 multi-user.target 之后,并把Type改成了idle.
    Before/After需要和Required配合使用,如下:
  4. systemctl daemon-reload

http://www.jinbuguo.com/systemd/systemd-analyze.html
https://www.mauras.ch/systemd-run-it-last.html
https://unix.stackexchange.com/questions/379363/how-can-i-start-systemd-service-units-in-orde

猜你喜欢

转载自www.cnblogs.com/dylanchu/p/11061264.html
ss