我在Respberry Pi 3 Model B +上设置了set(daemon_SRCS
src/main.cpp)
add_executable(daemon ${daemon_SRCS})
target_link_libraries(daemon
libcore
libpersistence)
install(TARGETS daemon DESTINATION bin)
文件,以在启动时检查网络连接,如果网络尚未连接,它将休眠5秒钟,但是当我重新启动它时,它显示了一些失败信息。
这是我的rc.local
脚本
rc.local
错误消息是:
#!/bin/sh -e
# Ping to the router
ping -c2 1.1.1.1 > /dev/null
# If the return code from ping ($?) is not 0 (meaning there was an error)
while [ $? != 0 ]; do
sleep 5
done
sudo /usr/bin/python3 /usr/local/bin/report-ip.py
当我使用[20.292216] rc.local [543]: connect : Network is unreachable
[FAILED] Failed to start /etc/rc.local Compatibility.
See `systemctl status rc-local.service` for details.
获取更多详细信息时,它显示:
systemctl status rc-local.service
report-ip.py 只是一个Python脚本,可以检查我的公共IP并发送电子邮件以通知我公共IP是否已更改。
这是该python脚本: Link