Strings in Java : equals vs == [duplicate]

I am running a script on a remote server. I ran the script in screen, however I need to stop it before it completes since I need to update the script. I can easily detach from screen, however, is there a way to kill a screen process?


Solution 1:

CTRL+a and then 'k' will kill a screen session.

Solution 2:

There are a couple of 'screen' ways to kill a specific screen session from the command line (non-interactively).

1) send a 'quit' command:

screen -X -S "sessionname" quit

2) send a Ctrl-C to a screen session running a script:

screen -X -S "sessionname" stuff "^C"

In both cases, you would need to use 'screen -ls' to find the session name of the screen session you want to kill ... if there is only one screen session running, you won't need to specify the -S "sessionname" parameter.

Solution 3:

I used this to quit hundreds of erroneous screen sessions created by a buggy command:

for s in $(screen -ls|grep -o -P "1\d+.tty"); do screen -X -S $s quit; done;

where: the grep -o -P "1\d+.tty" is the command to get session names with Perl-like name regex "1\d+.tty" which captures all sessions start with number 1, has some other numbers (\d) and end with .tty

Warning: You should test with this command first to see you get the exact list of sessions you want before apply the above command. This is to avoid quitting unwanted sessions:

for s in $(screen -ls|grep -o -P "1\d+.tty"); do echo $s; done;

I always to this echo test whenever the list in for loop is not clear, for example, the one generated by sub-command in $() expansion.

Solution 4:

previous answers didn't work for me on a winputty terminal and amazon ssh server connection.. but this one does work:

screen -S yourscreentitlehere -X stuff $'\003'

references:

  • Sending ctrl-c to specific screen session
  • $'\003' is ctrl+c http://donsnotes.com/tech/charsets/ascii.html
  • stuff is https://www.gnu.org/software/screen/manual/screen.html#Paste

Solution 5:

I am using putty, and it seems I am already in the screen and couldn't open and close. Every time I do "exit", I just close the putty window. Here is the termimal print

>>screen -r

    21063.unlimited (11/08/20 15:45:19)     (Attached)
    24054.cure6     (11/08/20 09:46:13)     (Attached)

There is no screen to be resumed. and

screen -S 21063.unlimited -X stuff $'\003'

does not do anything. I found that as simple as the following line works perfect

screen -x 21063.unlimited

it sends me back into the screen and from there "exit" works. Note that it is lower-case -x