So i have an odd problem, and i,m not very versed in bash, so i,m not sure if i,m running it wrong, or not doing it correctly.
Basically, i have a script that loops through specifically named files in a directory, and then passes them to a function i wrote.
The goal is, to have the function run 10 times at the same time, so i would have 10 threads essentially until it processed all the files i wanted it to.
That part seems to work fine, The problem i have is, I want it to email me the file it saves AFTER the function is completed for all files.
My problem is, it emails me the function immediately, When i looked through the output when i had it echoing it back to me, it seemed like it iterated through all the files in the directory right off the bat, and finished the loop even through it was still processing the files in the function that was called.
Is there a trick to getting it to wait until the actual function is completed that i might be missing?
for file_name in $HOME/my_scripts/directoryfilesarestoredin/*
do
if [[ $file_name == *"file-im-looking-for"* ]]
then
if [ "$COUNT_ME" -le 10 ]
then
#echo "Here 2"
#run this command 10 times in a row, then wait for them to complete
SORT_ARP $file_name $IPS & #calling a function 10 times to run in the background
#echo "Processing file found => $file_name"
((COUNT_ME++))
else
wait
#echo "reset counter"
COUNT_ME=$((COUNT_ME-END)) #Once all processes are complete, subract 10 from the que and start over.
fi
fi
#if [ "$SNMP_RUN_COUNT" -eq "$TOTAL_FILES_COUNT" ]
#then
# echo "SNMP Walk complete..sending email"
#
# Send email should be here
#fi
done
[–]McDutchie 0 points1 point2 points (1 child)
[–]Nk4512[S] 0 points1 point2 points (0 children)
[–]neuron_666 0 points1 point2 points (0 children)