komarek
Posts: 146
Joined: Fri Mar 31, 2017 1:19 am

Raspi stuck after some python script in background

Sun Aug 12, 2018 9:28 am

hello i am using a raspi 3b+ to run a few script in python (5 or 6)
These scripts are running some bot about twitter (with tweepy).. i take control of it through the vnc to launch scripts - every script in a single terminal window cause i need to debug the output)
it happens always after 3 or 4 days (sometimes less) that the raspi becomes unresponsive and i have to switch it off through the power switch.
I think it's a memory issue but i'm not sure... what u think it will be the solution and where do you think i should watch to find some useful log about it?

thanks

DirkS
Posts: 10010
Joined: Tue Jun 19, 2012 9:46 pm
Location: Essex, UK

Re: Raspi stuck after some python script in background

Sun Aug 12, 2018 11:33 am

komarek wrote:
Sun Aug 12, 2018 9:28 am
I think it's a memory issue but i'm not sure... what u think it will be the solution and where do you think i should watch to find some useful log about it?
Well if you think it's a memory problem then you should probably start to monitor that regularly...
Most likely solution is to correct your programming errors.

User avatar
B.Goode
Posts: 8987
Joined: Mon Sep 01, 2014 4:03 pm
Location: UK

Re: Raspi stuck after some python script in background

Sun Aug 12, 2018 11:42 am

Another possible diagnostic technique:

Instead of running 6 scripts, only start 3 of them. If the system runs stable beyond your 3 day horizon it suggests the problem lies with one of the scripts that are not being run. Conversely if your system still fails it is probably due to one of the scripts being run.

Continue this process to refine and focus in on the culprit...

Some people call it 'divide and conquer', others refer to it as a 'binary chop.'

komarek
Posts: 146
Joined: Fri Mar 31, 2017 1:19 am

Re: Raspi stuck after some python script in background

Sun Aug 12, 2018 12:35 pm

DirkS wrote:
Sun Aug 12, 2018 11:33 am
komarek wrote:
Sun Aug 12, 2018 9:28 am
I think it's a memory issue but i'm not sure... what u think it will be the solution and where do you think i should watch to find some useful log about it?
Well if you think it's a memory problem then you should probably start to monitor that regularly...
Most likely solution is to correct your programming errors.
do you mean i should make a script that logs out the memory level every xx minutes?
good idea

DirkS
Posts: 10010
Joined: Tue Jun 19, 2012 9:46 pm
Location: Essex, UK

Re: Raspi stuck after some python script in background

Sun Aug 12, 2018 12:46 pm

komarek wrote:
Sun Aug 12, 2018 12:35 pm
do you mean i should make a script that logs out the memory level every xx minutes?
Whatever works best for you...
Although I do think you should also keep an eye on the per-process memory use

komarek
Posts: 146
Joined: Fri Mar 31, 2017 1:19 am

Re: Raspi stuck after some python script in background

Sun Aug 12, 2018 12:54 pm

DirkS wrote:
Sun Aug 12, 2018 12:46 pm
komarek wrote:
Sun Aug 12, 2018 12:35 pm
do you mean i should make a script that logs out the memory level every xx minutes?
Whatever works best for you...
Although I do think you should also keep an eye on the per-process memory use
can you please suggest me which command i should use for that?

DirkS
Posts: 10010
Joined: Tue Jun 19, 2012 9:46 pm
Location: Essex, UK

Re: Raspi stuck after some python script in background

Sun Aug 12, 2018 1:01 pm

Maybe 'ps'?

Code: Select all

ps aux | grep python

komarek
Posts: 146
Joined: Fri Mar 31, 2017 1:19 am

Re: Raspi stuck after some python script in background

Wed Aug 15, 2018 11:32 pm

it might not be a memory problem
i made a script to monitor the free memory and i saw that when the raspi disconnected from my terminal and became unresponsive there was 320mb still free of memory.
at that time 4 python script were running
what do you suggest me to do?
where should i find something in the system logs?

Return to “Troubleshooting”