Kill all detached screen sessions

前端 未结 6 1710
时光取名叫无心
时光取名叫无心 2021-01-29 20:47

When I execute screen -ls, I see the following. How can I kill all the detached sessions?

There are screens on:

    84918.tty         


        
6条回答
  •  星月不相逢
    2021-01-29 21:26

    Combining Edward Newell's and Rose Perrone's solutions into a more readable and "screen" like solution.

    Add below to your .bashrc or .bash_profile.

    # function for killing all detached screen sessions
    killds() {
        detached_sessions=$(screen -ls | grep Detached | cut -d. -f1 | awk '{print $1}')
        for s in ${detached_sessions}
        do
            screen -S "${s}" -X quit;
        done
    }
    

提交回复
热议问题