#!/bin/bash IP=1.2.3.4 while true; do echo "**********************************************">>/root/ping_and_time.log echo `date +%y-%m-%d-%H:%M:%S` >>/root/ping_and_time.log ping -c 5 $IP >>/root/ping_and_time.log echo "----------------------------------------------">>/root/ping_and_time.log sleep 20 done