I have been using screen for a while, but the process I am running seems to terminate at times, closing the screen out. So I have to reopen the screen again.
I was wondering if it was possible to have a shell script, or just a single instruction executed on screen termination, inorder to reopen the screen automatically unless if I force close it
I love how easy it is to send commands to GNU Screens and i would love to still have that functionality.
edit: In the best case scenario,my screen shouldnt terminate unexpectedly, but if it does. I want to do two things, 1) log time and 2) reopen screen with exact same parameters. but if reopening screen has the screen terminate again. I want to exit out. I would also want to be able to exit out on demand. A shell script would be bad imo, because of nesting of screen, and not enough time to force the upper screen to close, though i could add a sleep timer... anyways this is just a bodged method, I was interested in a better way to achieve this.
screen
, so it's a general approach. But even if a screen-specific solution exists and you would prefer this, I think you should edit and add details to the question: should the command be resurrected (1) always? (2) or only if it succeeds? (3) or only if it fails? (4) Including (or excluding) when it's interrupted on demand with Ctrl+C? // The simplest example is likewhile true; do your_command; done
. It doesn't rely onscreen
but I believe you can run it insidescreen
.screen
– process. The process dies and screen dies. My idea was like:screen
– script – process. When the process dies, the script can do anything you designed it to do. It can restart the process, write to a logfile, increase count or exit, or whatever. I think thescreen
will notice nothing unless the script exits. And the script exits upon conditions you choose.screen
with the script inside and let the script resurrect the command if needed. You can do this from another, outer script if you want to automate the whole process. There is at most one outer script in total, exactly onescreen
in total, exactly one inner script in total, and at most oneyour_command
at any given time (but possibly many in total).