I want to find a Terminal command that will provide a timestamped ping every second for a period of time (say 5 minutes) and then pause for another period of time (say 30 minutes) and then repeat that process until I stop it. I will need to let it run for days.
In other words, what I want is sort of a combination of the following 2:
1) ping 8.8.8.8 | while read line; do echo `date` - $line; done
2) ping 8.8.8.8 | while read line; do echo `date` - $line; sleep 1800; done
(1) provides a ping listing every second with a timestamp, while (2) does the same thing but every 30 minutes instead of every second. I can use (1) but it generates way more data than I need. (2) provides the pauses I need but cannot catch the events I'm looking for (which last about 4 seconds, see below).
Although not needed to answer my question, the reason I want this is to deal with an intermittent internet connectivity problem. By using (1) above I have found that most of the time my internet connection is fine, but every couple of days or so there will be periods (lasting hours) during which I get unusually high pings for about 4 seconds, and this repeats every 15 seconds or so. But using (1) to figure that out meant a lot of unnecessary data collection. Also, I have a separate script which will plot the data and there are just way too many data points to plot conveniently since I need to collect for days.
I'm running OS 13.2 on a MacAir M1