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: MN
Subject: Re: wait until the file is done
Date: Fri, 30 Oct 2020 17:44:07 +0100

Thank you for your quick response.
It's a propriatery video editing software and it has not command line 
interface at all.
So I've been thinking about this for a while and I think I can determine 
precisely when the process is done.
I'd use it only for exporting videos, so the size of the file 
continuously grows until it's done.
If I knew how to compare the current filesize with a previously 
measured data then I would know if it's still being exported or the file 
is done. (Do I have to redirect the output into a file?!)
In other words; if the size of the file hasn't changed in 10 minutes 
then it's done.
The problematic part is that I don't know how to compare it with an 
older measurement.

until (( du -b "$1" | cut -f 1 = )) #it's incomplete
#there may be a nicer way to trim off the rest
do sleep 10m;
done

or if it were safer I could compare their md5 hashes.

On 20-10-30 11:30:34, Greg Wooledge wrote:
> 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.

-- 
Best Regards,

MN
e: promike1987@gmail.com



reply via email to

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