$ while ! ping -c1 the_host_down; do sleep 1; done && date | mail -s 'the host is back!' email@example.com
ping -c1 host sends just one ping and exits with success or error.
while will keep running until the ping succeeds
- When the ping succeeds the while loop will end, and an email will be sent with the date as the message
- Depending on your system the parameter for sending a single ping might be different from
- Depending on your system the mail command might be different or work differently