我的笔记本电脑(Ubuntu18.04.3LTS)经常在linux上重新启动radvd之后才能获得ipv6路由信息。那一切都很好。有什么想法可以让我不需要人工干预就能让这件事一直工作下去?
发布于 2020-04-12 20:12:10
也许更好地理解事情是如何崩溃的,但是您的问题是在不需要人工干预的情况下重新启动服务;所以这就是我要处理的。
创建一个systemd服务& timer来执行重新启动radvd服务的脚本。将以下所有内容复制到Linux上的单个文件中,chmod 700文件并使用sudo执行该文件。显然,将计时器部分中的“24小时”改为“12小时”或其他适合的小时数:
#!/bin/bash
cat <<'EOF'> /root/radvd-restart.sh
#!/bin/bash
#
systemctl restart radvd.service
EOF
cat <<EOF> /etc/systemd/system/radvd-restart.service
[Unit]
Description=Restart radvd Service
[Service]
User=root
Group=root
Type=simple
ExecStart=/bin/bash /root/radvd-restart.sh
[Install]
WantedBy=multi-user.target
EOF
chmod 644 /etc/systemd/system/radvd-restart.service
cat <<EOF> /etc/systemd/system/radvd-restart.timer
[Unit]
Description=Executes /root/radvd-restart.sh every 24 hours
[Timer]
OnUnitInactiveSec=24h
Unit=radvd-restart.service
[Install]
WantedBy=timers.target
EOF
chmod 644 /etc/systemd/system/radvd-restart.timer
systemctl daemon-reload
systemctl enable radvd-restart.service
systemctl enable radvd-restart.timer
systemctl start radvd-restart.service
systemctl start radvd-restart.timer同样,更好地理解事情是如何被破坏的,但这将满足您的要求,不再需要手动启动服务以使其正常工作。
https://askubuntu.com/questions/1176836
复制相似问题