2

I have a python script that runs fine when I run it via python3 script.py & on the the google vm, but then when i detach it with a screen and leave it run a couple iterations on its own I come back to check and it gets killed.

I think it might be something to do with high cpu usage, i tried to do a while true loop and sleep the program for a while, then i tried to use apscheduler or just scheduler or even nice -n 19 python3 script.py but neither worked out, the thing is that the script seems to run fine the first time or even first two times, but then it gets killed.

Here is how I run my script, is there anyway i can solve this without upping my CPU? I think I have a small machine on vm.

schedule.every(10).minute.do(scheduled_job)
print('STARTED PROGRAM')

while True:
    schedule.run_pending()
    time.sleep(1)

1 Answers1

1

Use /usr/bin/time --verbose python3 script.py to measure memory used by a single job run, or use ps axu or top to do that for a continuously looping task. Verify that you malloc less than the VM container agrees to provide.

If you see your process killed while testing on a small linux host, look for clues in the log: $ zgrep oom /var/log/{syslog,messages}*

J_H
  • 17,926
  • 4
  • 24
  • 44