Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Exit a Screen after a script is finished

When a script that I started in a screen is finished can I tell it to close the current Screen it's in? If so how? I know I can do "ctrl + a" then k, then y. To kill it but Im not there to issue those buttons. And I tried adding "exit" to the end of the script which doesn't seem to close it ether.

I also have a script that will auto start another script in a screen, this seems to work, but Im not 100% sure that I got all the syntax right?

screen -dm -S "script0$scriptID"; sleep 1; screen -S "fscript0$scriptID" -X screen ./script.sh "$input1" "$input2"

Thanks any help.

like image 228
Mint Avatar asked Oct 02 '09 13:10

Mint


People also ask

How do I exit a screen without killing the process?

Type 'quit' and Enter to leave the current screen session. Note that this will remove your screen session. Ctrl + A and then K will only kill the current window in the current session, not the whole session. A screen session consists of windows, which can be created using subsequent Ctrl + A followed by C .

How do I get out of a screen session?

Leaving Screen Terminal Session First, we are using “Ctrl-A” and “d” to detach the screen. Second, we can use the exit command to terminating the screen. You also can use “Ctrl-A” and “K” to kill the screen. That's some of the screen usages on daily basis.

How do you exit a script?

One of the many known methods to exit a bash script while writing is the simple shortcut key, i.e., “Ctrl+X”. While at run time, you can exit the code using “Ctrl+Z”.

How do you exit a shell script gracefully?

To end a shell script and set its exit status, use the exit command. Give exit the exit status that your script should have. If it has no explicit status, it will exit with the status of the last command run.


1 Answers

This command will cause the current session of screen to quit:

screen -X quit

The syntax of the command in your second question looks OK to me. Can you be more specific about where you think there might be a problem?

like image 170
Dennis Williamson Avatar answered Sep 30 '22 07:09

Dennis Williamson