With this I can check, that there is internet connection. if there is no internet connection (succesfull pings to this 2 places), then it waits 600 sec, then it runs along:ping -W 1 -c 4 www.google.com >& /dev/null && ping -W 1 -c 4 www.yahoo.com >& /dev/null || sleep 600But: how could I rewrite this one line, so that it loops until there is internet connection?
internet connection checker one-liner
linux;shell;networking;ping
while ! ping -W 1 -c 4 www.google.com >& /dev/null ||      ! ping -W 1 -c 4 www.yahoo.com >& /dev/null; do  sleep 600doneThough I'd just test connectivity to an IP address; 8.8.8.8 is Google's public DNS server (it has very high availability). Testing whether DNS works is unreliable anyway because the entry may be in the cache.while ! ping -W 1 -c 1 8.8.8.8 >&/dev/null; do sleep 600; donePing isn't always the best way to check internet connectivity. Many places (especially enterprise networks) block all but web access. You can test whether the web is working by downloading a file from a high-availability server. This tests DNS as well, at least from the HTTP proxy's point of view (which again is often what matters).while ! wget -q -O /dev/null --no-cache http://www.google.com/; do sleep 6000; done