Bash Script to Run multiple jar simultaneously on Ubuntu
Hi
I used the following script to run multiple nodes on single instances. Basically, this script runs the same jar file using for loop on a different port as a parameter.
The below code loop through port number 8001 to 8020
#!/bin/bash
echo "welcome"
ls
echo "this is the whole list of dir"
cd server
echo "entered server folder where jar files are kept"
for i in {8001..8020}
do
java -Xmx64m -Xms64m -jar A6.jar nodes-list.txt $i &
echo "running $i A6.jar"
done
save it as A6.sh
Now to run this use double dots . ./a6.sh
ubuntu@ip-172-31-27-28:~$ . ./a6.sh
This will start all jar instances parallel because & is used in for loop.
Hope this will help.
Comments