53 lines
1.7 KiB
Bash
Executable File
53 lines
1.7 KiB
Bash
Executable File
#!/bin/bash
|
||
#####################################################################################################################################
|
||
# Author: Zhang Shuai #
|
||
# Date: 2019-08-26 #
|
||
# Description: End a MPI Gazebo simulation task #
|
||
# Usage: ./MPI_Gazebo_end.sh [hostfile] [shell's path] #
|
||
# Example: ./MPI_Gazebo_launch.sh hostfile ~/Git/Gazebo_Distributed_MPI/mpi_run #
|
||
#####################################################################################################################################
|
||
|
||
host_file=$1
|
||
shell_path=$2
|
||
|
||
host_count=0
|
||
hosts=()
|
||
|
||
#获取hostfile文件中的host名字
|
||
while read line
|
||
do
|
||
if [ -n "$line" ]
|
||
then
|
||
temp=${line% *}
|
||
hosts[$host_count]=$temp
|
||
let host_count=$host_count+1
|
||
fi
|
||
done < $host_file
|
||
|
||
echo "host_count:$host_count"
|
||
|
||
for((i=0;i<host_count;i++))
|
||
do
|
||
echo "host_name:${hosts[$i]}"
|
||
done
|
||
|
||
#登入各节点kill相关进程以结束仿真(1.目前方式比较暴力,后续改进。)
|
||
for((i=0;i<host_count;i++))
|
||
do
|
||
ssh -f -n ${hosts[$i]} > /dev/null 2>&1 "cd $shell_path;
|
||
./kill.sh;
|
||
./kill.sh;
|
||
./kill.sh;
|
||
./kill.sh;
|
||
./kill.sh;
|
||
./kill.sh;
|
||
./kill.sh;
|
||
./kill.sh;
|
||
./kill.sh;
|
||
exit"
|
||
echo "${hosts[$i]}:close_good"
|
||
done
|
||
|
||
echo simulation_done!
|
||
|
||
exit 0 |