Linux - Check if python script is running in screen and run if not [closed]
2024/11/16 23:35:19
I am using "screen" to run a number of python scripts in AWS (linux build). One of those scripts will sometimes fail, for one reason or another. I would like to write either a) a python script or b) some kind of linux command line script to watch what python scripts are running, and if the target 'script.py' its not running then to rerun it.
For example:
import time
while(True):if script.py is running:time.sleep(5)else:open new linux screenpython3 script.pydetach screen
I'm sorry for this being vague, I never learned command line stuff, and I use it once in a blue moon. Screen took me a day to figure out how to use..
Thanks so much
Answer
ensure that flaky script keeps running
Your proposed approach could be made to work.
But a nanny script would be much simpler.
Call it e.g. nanny.sh.
#! /usr/bin/env bashwhile true
doscript.pysleep 1 # pause, so if script.py immediately dies we don't burn a core
done
Now we have replaced your "sometimes we randomly find script.py no longer running"
situation with one where we're confident that the nanny
is always running.
Diagnosing / fixing script.py is left as an exercise
for the reader. Fortunately it now is a less urgent matter.
I made my code like below....But as i input the data such as spam & number, previous data is deleted.So id like to make multiple value in one key...
(i think using list is kinda good method)For exa…
Im new to pygame and trying to make a platformer game thats based on this tutorial: http://programarcadegames.com/python_examples/show_file.php?file=platform_scroller.pyI cant quite figure out how to …
Closed. This question needs details or clarity. It is not currently accepting answers.Want to improve this question? Add details and clarify the problem by editing this post.Closed 8 years ago.Improve…
Closed. This question needs details or clarity. It is not currently accepting answers.Want to improve this question? Add details and clarify the problem by editing this post.Closed 5 years ago.Improve…
Being a beginner in python I might be missing out on some kind of basics. But I was going through one of the codes from a project and happened to face this :AttributeError: NoneType object has no attri…
Hi Can someone please help me to change this code so that it wont get data from keras mnist. instead it will be getting data from local folder. where do i need to make changes in it. and where in this …
Im trying to create a column his values is the subtraction of two column but I found strange values:Patient["Waiting"] = Patient["Appointment"] - Patient["Scheduled"]Sched…
Closed. This question needs debugging details. It is not currently accepting answers.Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to repro…
Closed. This question is opinion-based. It is not currently accepting answers.Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.Clo…