'Python script running as screen process gets "Killed" on Ubuntu / AWS EC2

I want to have a python script running on my Ubuntu instance constantly. It's an AWS EC2 a1.medium instance and the script is taking pretty much 100% of the CPU constantly.

I start the script with screen <run script>, however it gets killed randomly and I have no idea why. One time I had it running in the foreground and I saw "Killed" as the last output of the process.

I tried running it as root with sudo screen <run script> but I get [screen is terminating]. Not sure if root would even help though.

Is there anything I can do to troubleshoot this? I tried with -L -Logfile <filename> with proper permissions for the file, but it stays empty, so I really have no idea how to tell what went wrong.



Solution 1:[1]

What is nature of your script? Is it CPU/Memory bound ? I am assuming you are over utilising vCPUs provide in a1.medium EC2 instance

You can also take a look at this to understand steal time

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Shakeel