how to control how many times loop will reply ?
by uyjjhak from LinuxQuestions.org on (#5125W)
Long time ago I have used in my script:
Code:for i in `ls /directory`
do command &
doneAnd that working, but as the files qty increased I am getting OOM errors as that command starts all occurencies in one time.
I would like to find any way to limit number of parallel loop runs:
Like run the loop 5 times, when one of the occurencies will finish, andd another one, and after that add next one, or two, or any number to keep 5 concurrent
Is that possible ? That is the script which I am using to make lot of connections to remote storage - overnight I would utilise 100% of tunnel bandwith and the 'command' doesn't support multithreading :(.
Yeah, I see parallel package, but I can't change this scripts :(
regards


Code:for i in `ls /directory`
do command &
doneAnd that working, but as the files qty increased I am getting OOM errors as that command starts all occurencies in one time.
I would like to find any way to limit number of parallel loop runs:
Like run the loop 5 times, when one of the occurencies will finish, andd another one, and after that add next one, or two, or any number to keep 5 concurrent
Is that possible ? That is the script which I am using to make lot of connections to remote storage - overnight I would utilise 100% of tunnel bandwith and the 'command' doesn't support multithreading :(.
Yeah, I see parallel package, but I can't change this scripts :(
regards