linuxbashshellgnu-screen

Closing screen by bash script


I am trying to close a detached screen(1) using a script.

How could I do it? I am starting the screen using screen -dmS name stuff_to_execute but it creates a new one when ran again, I want to ensure the old screen quits. I tried searching how to do this but found nothing.


Solution

  • From the screen(1) manpage:

    -d -m Start screen in "detached" mode. This creates a new session but doesn't attach to it. This is useful for system startup scripts.

    So I don't think -dmS will ever close a running screen(1).

    Do you want to kill the specified screen(1) instance? Or do you simply wish to force it to be detached?

    If you want to kill: screen -S name -X quit

    If you want to detach: screen -dS name