How to keep my c++ code running in aws hpc ec2?

  amazon-ec2, c++

I have designed scientific experiment using C++, I run it in my PC with linux partition, and it took 2 weeks running (16 GB RAM).
Therefore, I am trying to run it AWS EC2 instance.
I created the instance, connect to it using mobaXterm ssh connection. I run the c++ code using .sh file:


cd code

g++ -std=c++11 file1.cpp file2.cpp file3.cpp main.cpp -o myExperiment

./myExperiment 8 0

./myExperiment 8 20

./myExperiment 8 40

./myExperiment 8 60

There are actually 24 line ./myExperiment with different argument1 and argument2

if I exit mobaXterm using Exit button, I assume that my experiment is still running in the EC2 instance because the instance state is Running in EC2 Dashboard. However, if I re-connect ssh using mobaXterm again I found that the experiment restart execution from ./myExperiment 8 0 then jump to ./myExperiment 8 60 then jump again to ./myExperiment 8 0

I have used HPC node from other provider(but they gave me 4GB RAM only) I used Slurm sbatch commands which still running even if exit mobaXterm.

(1) How can I keep the same behavior(my code running even if close ssh) using AWS EC2 instance?

(2) why my code is not running in the same order specified in the .sh file? and keep jumping between the arguements combinations?

Source: Windows Questions C++