By using AWS re:Post, you agree to the Terms of Use

How to keep a process running on my EC2 instance via cloud9


I have a simple python script on my cloud9 environment that I want to be running constantly. When I run it using nohup python3 & in a cloud9 terminal, it starts a process that runs successfully in the background. However, shortly after exiting the terminal and my browser, the process is automatically killed. When I set up my EC2 instance, I chose the option for it to never hibernate or shut down. Shouldn't I be able to run a process indefinitely on it? I'm fairly new at this, so I would appreciate any answers or help.

asked 3 years ago523 views
5 Answers


Just a few questions to help us troubleshoot this problem.

  1. What kind of process do you run? Is it IO/CPU intensive?
  2. What type of instance do you use and what OS?
  3. If you do not close terminal and browser does process run with no interruption even after some time?
  4. Approximately after what period of time process stops?


profile picture
answered 3 years ago
  1. The process uses about 1% of the CPU.
  2. I use a t2.micro instance which uses Amazon Linux.
  3. Yes, with the terminal and browser open, I have not experienced any interruptions in the process. I've had the browser open for up to 8 hours, and it works smoothly the whole time.
  4. I'm not sure exactly how long. My best guess is within a few hours at most.

By the way, apparently I can only make one post per day, so if you ask more questions I will not be able to respond for another 24 hours.

Edited by: ineedhelpbadly on Aug 14, 2019 8:15 AM

answered 3 years ago

Thanks for details!

One more questions: when you close your IDE and then after some time returns to it, does your EC2 instance stops and starts again? Or is it running? You can see that instance was stopped if on loading screen for Cloud9 you will see that Cloud9 attempts to starts EC2 instance.

profile picture
answered 3 years ago

The EC2 instance continues to run. I can also SSH into my instance at any time and it is always running. by SSH-ing directly into the instance and running the script with nohup python & , I can now get the script to run for about 24 hours before it stops running.

answered 3 years ago

Hi, can you please explain what your script is doing or, if possible, add python script to this thread.
Here are a few things I would recommend to help debug..

1. launch to see stdout/stderr output - nohup python > /tmp/nohup.out&
2. If you don't have try/except/finally blocks around the code, add them to help debug and handle any unexpected exceptions (if an exception is causing it to die)
3. Is it possible your script is running out of resources and dying? For example, maybe "Too many open files" because your script is not closing file handles? (ulimit -n shows 4,096 max files in cloud9 by default).
4. Does your python script just run in a loop performing things every X minutes? If yes, maybe consider creating a scheduled cron job that just runs the script every X minutes.
5. If your python script is running as a "server" accepting connections, can you run it as a daemon?
6. Try launching your python script on a regular EC2 instance to see if you can reproduce the problem there.


answered 3 years ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions