phoganuci
phoganuci

Reputation: 5064

Running shell script in detached screen session. Must kill. How?

I am an Ubuntu Linux user. I am running jobs remotely and started a screen session. During this session I sourced a file containing a long list of command lines arguments to be executed. I was forced off of the connection and now the jobs are still running in this screen and I am unable to kill them.

Does anyone know how to kill all running and future commands this script will execute. Thank you in advance.

Upvotes: 1

Views: 3048

Answers (4)

troyfolger
troyfolger

Reputation: 2538

There are a couple of 'screen' ways to kill a specific screen session ...

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.

Upvotes: 0

sleske
sleske

Reputation: 83628

If you just want to kill everything there is no need to even reattach to screen.

Just list the offending process(es):

pstree -pla

then kill whatever needs killing. Note that if you kill a process higher up the process tree, its children will (usually) go away as well.

Upvotes: 3

Stobor
Stobor

Reputation: 45132

Use ps to identify the pid of the shell process (bash, tcsh, etc), then kill that...

Upvotes: 2

David Schmitt
David Schmitt

Reputation: 59356

Reattach the screen with

screen -D -r

then you can resume your session.

Upvotes: 2

Related Questions