I was trying to write script witch will ping some address, for example Google.com, and when connection is lost, write the log in to file. I don't know how to do it. Example:ping goodle.com if connected just pingif not connected write log into file
Script to write logs in to file
bash;scripting;ping
if ! ping -c2 google.com >/dev/null 2>&1; then    printf '%s\tgoogle.com not reachable\n' $(date) >>logfilefiThis makes ping try to ping Google twice. If it fails (ping returns a non-zero exit status), a message is added to a logfile.