help-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: wait until the file is done


From: Greg Wooledge
Subject: Re: wait until the file is done
Date: Fri, 30 Oct 2020 11:30:34 -0400
User-agent: Mutt/1.10.1 (2018-07-13)

On Fri, Oct 30, 2020 at 03:37:12PM +0100, MN wrote:
> Hello.
> I use a video editing software which lacks the ability to turn off the 
> computer when it's done.
> I thought I would make a function that monitors the size of the video file 
> and waits if it's still being modified.
> I guess this should be an 'until' loop.
> 
> I'd use it like this $ waitfor ./video.mp4 && poweroff

The fundamental problem here is: how do you know when the video editing
is "done"?  This requires deep knowledge of how the editing software
works.  The best solution, if at all possible, would be for the editing
software process to terminate when it's done.  Then you can just run
the editing software like:

editing-software -a -b -c -d video.mp4 ; sudo shutdown -h now

If the editing software does not terminate when the job is done, then
you have to cobble together some inferior approach.  You'll need to
guess, or ideally *know*, some details of how the editor works.  For
example, does it hold the file open the entire time that it's working,
and then close the file when done?  In that case, you can use something
like lsof or fuser in a loop, and wait until nothing has the file open
any longer.

Or, perhaps, you might know that there is never any *POSSIBLE* set of
conditions in which the size of the output file remains unchanged for
ten minutes while the editing is ongoing.  In that case, you could
poll the file size periodically, and react when the size has not
changed for 10 minutes.

You get the idea, I hope.  This is not really a problem that you should
be solving in bash, so any "solutions" you come up with are going to be
horrible hacks.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]