I have a node.js file that accepts an integer arg.
I'm trying to write a bash script that looks for number of available cores and launches main.js for each available core.
For 1 core it should call:
node main.js 3000 &
For 2 cores:
node main.js 3000 &
node main.js 30001 &
And so on...
This is my bash script:
#!/bin/bash
numCores=`getconf _NPROCESSORS_ONLN`
i=0
j=3000
while [ $i < $numCores ]
do
j=$($j+$i)
node /myApp/main.js $j &
i=$($i+1)
done
When I try to run it, I get this error:
bash launchnode.sh
launchnode.sh: line 5: 2: No such file or directory
main.js and launchnode.sh are in the same directory.
Any help?