Non-Exiting Screen Startup

I was trying to run screen in the background with a python script inside of it, however, when the python was exiting due to coding errors, the screen was quitting too. I could have turned on logging but I didn’t want to deal with screen log files all the time. I wanted the screen session to remain open, even if the python quit so I could reattach to it and see what was going on (like a normal command prompt). Here was the solution I came up with:

/usr/bin/screen -dm /bin/bash -c 'echo "your program here" ; /bin/bash'

Run this to reattach it later:

/usr/bin/screen -dr

One thought on “Non-Exiting Screen Startup

Leave a comment