I have some embedded machines which are on an unreliable connection which network manager unfortunately isn't handling well. Currently I need to check for connectivity and then restart network manager if we're not connected, as that will in most cases handle the specific situation we're seeing them fail in. I have the following script, which works fine when I run it by hand:
#!/bin/bash
host=http://google.com
timeout=60
if ! wget -S --spider --timeout=$timeout $host &>/dev/null; then
restart network-manager
fi
I currently have an entry in /etc/cron.d/
that has */15 * * * * root /usr/bin/check_connectivity
. I can see that the script is being run by reading the cron logs, but when I watch the network manager logs, I can see that even when I test with no connections active, it does not restart the connection. Running the script by hand succeeds and NM is restarted. There are no error messages in cron's logs and even when I remove the output dumping, I still get nothing back. I'm at a loss for why it's failing. I might think that it isn't able to talk to dbus properly, but if that were the case I'd see some error output.