Skip to content

Instantly share code, notes, and snippets.

@paulocanedo
Created November 10, 2021 18:55
Show Gist options
  • Save paulocanedo/8b46bc8210f6d4868b17df7963a4780e to your computer and use it in GitHub Desktop.
Save paulocanedo/8b46bc8210f6d4868b17df7963a4780e to your computer and use it in GitHub Desktop.
#!/bin/sh
#script para testar conectividade com internet, caso não tenha internet reinicia o sistema
tempo_timeout=3
tempo_espera_entre_ping=3
ip_avaliacao=8.8.8.200
while :
do
ping -q -c1 -W$tempo_timeout $ip_avaliacao > /dev/null
# if [ "0" = $? ]; then
# echo "não faz nada"
# elif [ "1" = $? ]; then
if [ "1" = $? ]; then
echo "reiniciando o PC"
/usr/sbin/shutdown -r now
fi
sleep $tempo_espera_entre_ping
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment