1

I have tried launching a EC2 instance from pycharm using a Python script. As part of the launch process, I have downloaded a .sh script from s3 and have executed below commands.

commands = [
    "aws s3 cp s3://sample/test.sh /home/ubuntu/test.sh",
    "chmod +x /home/ubuntu/test.sh",
    "sudo apt-get update",
    "./test.sh"
]

However, when the last command './test.sh' is executed, I want to get out of the flow and create few more instances. But, as the script ./test.sh is a long running script, its not exiting the loop. I would like to submit the job as a background Screen job, but, was not able to open a screen using python code snippets. I am using paramiko module to connect to EC2 instance.

2
  • Are you downloading and executing the script on your local machine? Also, could you provide the snippet of code that failed to open a screen session for you? Commented Dec 29, 2017 at 16:25
  • I have downloaded the script in EC2 instance. I changed the ./test.sh to "screen -d -m ./test.sh" and it worked. Commented Dec 31, 2017 at 20:59

1 Answer 1

3

I have changed the above statement from ./test.sh to screen -d -m ./test.sh and it did the trick for me.

Sign up to request clarification or add additional context in comments.

1 Comment

how to stop the same or how to know which is running next time i loggin?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.