Kill screen session using command line & bash

To kill an active screen, use the following command:

$ screen -S myscreen -X quit

To use this in a bash script, use the following:

# Kill screen if running
if [ $(screen -list | grep "$sessionname" | wc --lines) -ge 1 ]; then
    echo "screen session $sessionname is running"
    screen -S "$sessionname" -X "quit"
Did this help you? Please let me know with a comment. Thank you
Posted .

Comments (RSS)

Leave a comment