How to terminate screen from bash script?

Bo Berglund bo.berglund at gmail.com
Tue Jul 19 20:42:02 UTC 2022


I have a video editing script that cuts pieces out of a video file based on
start,length time pairs on the command line.
The script decodes the arguments and builds a big ffmpeg command to do the cut
and concatenate using re-encode to make transitions smooth. This works fine but
is a bit slow (takes 5-10 minutes per video).

So I am using screen to be able to work with the next video.

My process:
- Find the cut points and lengths for the parts outside of screen
- start screen
- Make a call to the edit script with the proper arguments
- Detach from screen using Ctrl A-D
- Repeat above for the next video

In order for the screen session to terminate I have added the  following at the
end of the script call command:  ; exit
This causes the screen session to end when it is done so no ghost screens
remain.

But it seems like the screen session termination should pe possible to add to
the script itself, but I have not been successful in doing so...

So is there a way to finish a script running in screen with a screen termination
command (exit) such that it will terminate the screen in which it runs?

I tried reading the man page but it is HUGE and very hard reading so I gave up.

All googling attempts I do bring up ways to *detatch* from the running screen
window, but I want to *terminate* it automatically once the job is done...


-- 
Bo Berglund
Developer in Sweden





More information about the ubuntu-users mailing list