My server have 16 cpu. My purpose is plan to write a script that able to utilize all the cpu instead of utilize only 1 cpu to run the progress. After first 16 files is completed, it will automatic run through the next 16 files, etc.
I got try to edit my bash script by adding "&":
for f in *.txt
do
./progran_name $f > $f.out &
done
Unfortunately, the above script will utilize the cpu based on total number of my *.txt. This is not advice since over cpu utilized will end up stuck my server
Thanks for any advice to solve my doubts.
Perhaps GNU Parallel would be of some use to you. If you are interested in it (i.e., it seems promising), there is a video (part one of two) about it which you can watch on YouTube.
Is ok about that.
Still thanks for your assist
You can update me anytime once you have better idea to write a script to utilize all the cpu in server for running a progress.
Thanks first!
Hi!
The best idea (what I can imagine) is to get GNU Parallel. Especially for 16-core monsters. I played with it a little - it's easy to use and you can say it how many jobs it should execute. But no one of my boxes have more than 2 cores (((.
find . -name '*.txt' | parallel -j4 ./prog
It works (here) as xargs.
And don't confuse GNU parallel with parallel from "moreutils".
No, you definitely don't have it - it's too fresh. You should compile it. But it has not to have root privileges and you can install it in your $HOME/bin. The link - GNU Parallel - GNU Project - Free Software Foundation
But I really used 0install (for debian based, ubuntu in my case):