Friday, September 5, 2014

Script to create in a bash script

Here is a shell script I use to create multiple nohup commands and put them in bash script called scripts1to100.txt. Each nohup command runs a matlab function called  runFunctionWithVariablesAandB which takes a and b as inputs.

for i in {1..100};
 do
let a=(i-1)*100+1;
let b=i*100;
echo nohup matlab -nodisplay -nosplash -r \"runFunctionWithVariablesAandB\($a:$b\)\; exit\;\" \> \/home\/logs\/batch$i.log \& >>scriptsFor1to100.txt;
 done

Once script1to100.txt is ready, you can run it by calling 'bash script1to100.txt'

Note: This particular script launches 100 parallel runs of runFunctionWithVariablesAandB, each with a different set of inputs.

No comments: