Search code examples
amazon-web-servicesamazon-ec2

I want to run a process in aws ec2 after closing my ssh session


I have a bash script which will take 5-6 hrs to complete and yesterday i accessed aws 12 month free tire and running ec2 (ubuntu) on it ,i want to run that bash script even after i close my main machine ...how can i do this ?


Solution

  • Assuming this is on linux system, you can run your script in the background using & optons. Something like this

    yourBashScript.sh &
    

    Where & tells the shell to run it in the background. So even if you close the shell or end your ssh session, it will keep running in the background till it finishes the job or crashes due to any error.

    You can always check whether your script is running or not using ps command. Something like this

    ps -eaf | grep yourBashScript
    

    this may return the process information for your script, if it is in running state.