不知从什么时候开始,发现开机后ss总没有成功启动,每次开机后总要restart一下ss-libev的service才能上谷歌。
今天解决一下:
查看一下unit
cat /usr/lib/systemd/system/[email protected]
```ini
[Unit]
Description=***-Libev Client Service
After=network-online.target[Service]
[Install]
Type=simple
User=nobody
CapabilityBoundingSet=CAP_NET_BIND_SERVICE
ExecStart=/usr/bin/ss-local -c /etc/shadowsocks/%i.json
WantedBy=multi-user.target
```- 打印以下启动顺序
systemd-analyze plot > aaa.svg
可以发现ss的服务紧跟着network-online.target
就启动了,无线网卡的启动在它之后(并不知道这个顺序是否重要)。 - 修改一下unit
保险起见,把它改到 multi-user.target 之后,并把Type改成了idle.
Before/After需要和Required配合使用,如下:
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