I have a file system that is shared between several computers. I cannot open network connections between these computers so I have written a program to communicate via files. I have a server that checks a folder for the appearance of instruction files, it reads, executes and writes an output file and then creates a signal file to indicate the file is ready.
to check for a file with a while
loop
while [[ ! -e $READY_FILE ]]
do sleep 1
done
do something
The server gets and processes the file pretty much right away and makes the signal file but I am seeing a strange latency on the client side.
when the server and client are running on the same machine the latency is very low. When I run the client on a separate computer the latency is around 30 seconds.
time bash client.sh -f commands.txt
done
real 0m31.945s
user 0m0.048s
sys 0m0.314s
This is reproducible +/- 2 seconds.
I can kill the problem by making the client computer do anything with the working directory.
time bash client.sh -f commands.txt & sleep 5; ls $wd >/dev/null
real 0m5.120s
user 0m0.014s
sys 0m0.083s
time bash client.sh -f commands.txt & sleep 3.5; ls $wd >/dev/null
real 0m3.749s
user 0m0.011s
sys 0m0.055s
I can correct it in the program by changing the while
loop to
while [[ ! -e $READY_FILE ]]
do ls $wd >/dev/null
sleep 1
done
Now i get
time bash client.sh -f commands.txt
real 0m1.075s
user 0m0.004s
sys 0m0.056s
My question is why is there a 30 second delay for the test [[ -e $READY_FILE ]]
to detect the file?
Aucun commentaire:
Enregistrer un commentaire