How to cleanly end a process started by at?
Bo Berglund
bo.berglund at gmail.com
Tue Dec 8 11:12:30 UTC 2020
I am using my Ubuntu 18.04 server (no gui installed) to manage svn
server and a video website.
The videos I want to watch are part of a live stream sent during night
in my time zone, when I am sleeping.
I have created a script, which packages a call to youtube-dl to
download the stream.
But youtube-dl does not have a timeout argument so for live streams it
runs for exactly 6 hours before ending.
So I have created four at jobs in order to get each 6 hour section
every day.
But this means I have to wait until the download finishes before I can
get the video and view it.
Until it is done the video file remains a name.mp4.part file...
What I would rather do is to somehow set the youtube-dl call to only
run for say 60 minutes rather than 6 hours, then I could record every
video separately and get at them as soon as they finish.
When I run youtube-dl interactively and it is busy downloading (at
that time it is actually ffmpeg running) I can use the keyboard Ctrl-C
to stop the process and this makes the download stop cleanly leaving a
valid mp4 file. So it cleans up the file then exits.
I have tried using the timeout function in Linux, but that seems to
force kill the process including child processes all the way down to
ffmpeg. So it leaves the file.mp4.part file rather than cleaning up...
Is there any way to simulate whatever happens when I hit Ctrl-C on the
keyboard when my script is running interactively in a terminal
session?
Or else, how could I make youtube-dl stop before the 6h built-in
timeout?
--
Bo Berglund
Developer in Sweden
More information about the ubuntu-users
mailing list