Ping Spawning Out of Control

182 views Asked by At

I have a simple script (below), which needs to spawn 2 ping processes in the background, which will ping 2 hosts continuously.

Without the 'sleep 3' statement, the script spawns hundreds of ping processes until the server locks up. With the sleep statement, the script works properly, only spawning 2 processes.

This issue only occurs on RH5 servers. RH6 seems to work fine, without the sleep statement. My guess on the cause is that the scripts output is being buffered, and is somehow interfering with each other.

My 3 questions are, what is causing the pings to spawn out of control, how exactly does the sleep correct it, and is there a better fix than adding the sleep statement?

Thanks in advance for any info.

Script:

#!/bin/sh
ping 192.168.1.2 -q > /dev/null &
sleep 3
ping 192.168.1.3 -q > /dev/null &

OS Info: Linux wppra01a0326 2.6.18-402.el5 #1 SMP Thu Jan 8 06:22:34 EST 2015 x86_64 x86_64 x86_64 GNU/Linux

0

There are 0 answers