Let me start this by saying that I'm still learning bash scripting and I'm not aware of many things. If I miss something, feel free to scold me as you please.
Onward, I'm creating a simple bash script to run a ping to 2 different hosts and output to a file. I already got that covered, and it's working. Out of curiosity, I added in the script to output date after and before the ping output print, so I know how long it did take to run the pinging. I set ping to 1 second interval, 10 pings, 2 hosts. My first date (was a long time ago...) had 14:36:20 as hourstamp. The second date (after the ping) had 14:36:40 as hourstamp.
So, the date waited for both pings to finish. This means the pings ran sequentially.
Can I make them run concurrently, so I spend 10 seconds running the script instead of 20 seconds?
Here comes the snippet of my script:
date >> teste.txt cat hosts.txt | while read output do ping -c 10 -i 1 "$output" >> teste.txt done date >> teste.txt
There are several other things I will want this is script to do, but I promise I will only ask if I can't find a satisfactory answer on Barsa.
PS: hosts.txt is where I store the hosts I want to ping.