Как удалить скрины в linux

Kill Attached Screen in Linux

I created a screen «myscreen» in linux and it stopped responding abruptly. I closed the terminal and tried to reopen it. «screen -ls» shows that the screen is Attached. I tried the following commands but nothing responds.

screen -r myscreen screen -D myscreen screen -D -RR myscreen screen -X -S myscreen quit 

I am not sure if screen is a process. But «kill -9» will kill the entire process. But i want to kill the particular screen and leave the other screens uninterrupted.

11 Answers 11

alternatively, you can use the following command

screen -S SCREENNAME -p 0 -X quit 

You can view the list of the screen sessions by executing screen -ls

I notice the first command sequence only kills the last window if you have multiple windows open while the second actually kills the entire screen regardless of the number of windows.

Create screen from Terminal:

To go to particular screen:

give ctrl+d screen will get terminated 
 give or screen will get detached 

To kill a screen from Terminal:

You can use screen_name or process_id to execute commands.

This worked for me very well. Get the screen id via:

then kill the screen: kill -9 it now becomes a dead screen, then wipe it out with: screen -wipe

Reattach a session and if necessary detach it first

To kill a detached screen use this from the terminal:

screen -X -S "SCEEN_NAME" quit 

If you are attached, then use (from the terminal and inside the screen):

You could create a function to kill all existing sessions. take a look at Kill all detached screen sessions

to list all active sessions use screen -r

when listed, select with your mouse the session you are interested in and paste it. like this

Suppose your screen id has a pattern. Then you can use the following code to kill all the attached screen at once.

result=$(screen -ls | grep 'pattern_of_screen_id' -o) for i in $result; do `screen -X -S $i quit`; done 

i usually don’t name my screen instances, so this might not be useful, but did you try screen -r without the ‘myscreen’ part? usually for me, screen -r will show the PIDs of each screen then i can reattach with screen -d -r

Читайте также:  Linux изменить горячие клавиши

Yes, that was the first command I tried. but it didn’t respond. I tried to open as root user but the screen was not even detected for root user account.

You can find the process id of the attached running screen. I found it same as the session id which you can get by command:
screen -ls
And you can use following command to kill that process:
kill [sessionId] or
sudo kill [sessionId]

None of the screen commands were killing or reattaching the screen for me. Any screen command would just hang. I found another approach.

Each running screen has a file associated with it in:

The files in that folder will match the names of the screens when running the screen -list . If you delete the file, it kills the associated running screen (detached or attached).

Источник

How to Kill a Detached Screen Session

announcement - icon

The Kubernetes ecosystem is huge and quite complex, so it’s easy to forget about costs when trying out all of the exciting tools.

To avoid overspending on your Kubernetes cluster, definitely have a look at the free K8s cost monitoring tool from the automation platform CAST AI. You can view your costs in real time, allocate them, calculate burn rates for projects, spot anomalies or spikes, and get insightful reports you can share with your team.

Connect your cluster and start monitoring your K8s costs right away:

1. Overview

When using GNU screen, we can sometimes end up with detached sessions that need cleanup. In this quick tutorial, we’ll walk through a few options for killing a detached screen session.

2. Listing Sessions

Before we start discussing how to end existing sessions, let’s first go through listing existing sessions. First, let’s set up a couple of sample screen sessions. In a bash shell, let’s type:

% screen -dmS my_session_1 % screen -dmS my_session_2

This will create two sessions named my_session_1 and my_session_2. Notice we are not attached to either (thanks to the -d option). Now, let’s take a look at the sessions we created:

There are screens on: 84581.my_session_1 (Detached) 76340.my_session_2 (Detached)

Next, let’s talk about how to kill these sessions.

3. Attach and Kill a screen Session

One way we can kill a screen session is to attach and then kill it. So, let’s attach to the first session we created above:

Читайте также:  Driver bluetooth linux ubuntu

Our command prompt is now inside our session. So we can just type:

The session will end, and we should see:

Now we only have one session left:

% screen -list There is a screen on: 76340.my_session_2 (Detached)

If the screen session had more than one window, we’d have to type exit (or CTRL+a k) at every window before the screen session would end. An easier alternative is the quit command:

(Note: you need to hold CTRL+a while hitting the \ key.) This prompts us with a confirmation:

Really quit and kill all your windows [y/n]

We choose to close all session windows to end the screen session.

The above-attached scenario is straightforward because we created the screen session in the same window. Now, if there’s another terminal or user attached to the session we want to kill, we need a different command to attach. In our current terminal window, create a new session:

The -S will create the session and attach it to it. Now, let’s open a second terminal window and list our screen sessions:

% screen -list There is a screen on: 19643.my_session_3 (Attached)

Notice this is now “Attached” because we are attached in our first terminal. In our second terminal, we’re going to force the session to detach from the first terminal window and attach to the second terminal. In the second terminal, type:

Our second terminal is now in the screen session. Our first terminal shows a warning and is back at the terminal:

Now we can use exit as shown in the previous section.

4. Kill a screen Session Without Attaching

As an alternative to attaching to a session to end it, let’s look at a couple of ways to end a screen session without attaching.

First, let’s create a couple of sessions to kill:

% screen -dmS my_session_4 % screen -dmS my_session_5

Our two sessions are now created:

% screen -list There are screens on: 19665.my_session_4 (Detached) 19671.my_session_5 (Detached)

We can now use the screen command argument -X to send a command to a running screen session. The -S will allow us to specify the session that will receive the command. So, to send a quit command to my_session_4, we would use:

% screen -S my_session_4 -X quit

The screen -list shows our current sessions:

% screen -list There is a screen on: 19671.my_session_5 (Detached)

Lastly, we can always kill a screen session via OS commands. The numbers prepending the name are the PID of the screen session. To kill our last session, we can use kill:

Checking our screen sessions now, we’ll see:

% screen -list No Sockets found in /var/folders/wr/129xvd3dfecl/T/.screen.

5. Conclusion

In this article, we walked through various ways to kill a detached screen session.

Читайте также:  Anaconda для linux mint

Источник

Убить отдельный сеанс экрана

«kill» будет убивать только одно окно экрана. Чтобы «убить» весь сеанс, используйте quit .

Пример

$ screen -X -S [session # you want to kill] quit 

Вы можете убить отдельный сеанс, который не отвечает в сеансе экрана, выполнив следующие действия.

    Введите screen -list , чтобы идентифицировать сеанс отдельного экрана.

~$ screen -list There are screens on: 20751.Melvin_Peter_V42 (Detached)
screen -r 20751.Melvin_Peter_V42

Комментарий @laffuste работал для меня, но quit и :quit приводят к command not found на моем удаленном сервере Linux (возможно, виноваты различия между версиями ОС или экрана)

Легче убить сеанс, когда дано какое-то значащее имя:

//Creation: screen -S some_name proc // Kill detached session screen -S some_name -X quit 

Список экранов:

There is a screen on: 23536.pts-0.wdzee (10/04/2012 08:40:45 AM) (Detached) 1 Socket in /var/run/screen/S-root. 

Убрать сеанс экрана:

ИМО этот ответ является наиболее полным и лучше всего написанным, однако это должен быть просто screen -list . Я попытался отредактировать, чтобы исправить это, но StackOverflow сказал мне, что я не изменил достаточно символов. : /

@cwc Я сделал редактирование, которое вы указали. Как правило, варианты несколько букв взять двойной тир — , но параметры экрана нет.

Вы можете просто пойти в место, где размещается и запускаться сеанс экрана:

 There is a screen on: 26727.pts-0.devxxx (Attached) 1 Socket in /tmp/uscreens/S-xxx.  

В каталоге uscreens больше нет файла 26727.pts-0.devxxx . Теперь, чтобы убедиться, что просто введите это:

Это единственное решение, которое будет работать, если экран «завис», т.е. не мертвый, но не может быть привязан к.

Это помогло мне, когда экран был полностью заблокирован, но мне также нужно было найти и убить сам процесс. ps aux | grep screen нашел pid, и я выпустил команду kill чтобы удалить ее. В зависимости от того, что у вас было на экране, у вас также могут быть временные файлы и блокировки для очистки.

Источник

Оцените статью
Adblock
detector