[mythtv-users] stagger start times for simultaneous recordings?
Mark J. Small
msmall at eastlink.ca
Mon Oct 24 15:05:53 UTC 2011
On October 23, 2011, Mike Holden wrote:
> Ronald Frazier wrote:
> >> Were it me, I'd try and implement some crude form of "locking"
> >> inside the channel-change script(s), so that one instance would
> >> loop and sleep/wait until the other has finished its thing.
> >
> > A while back I had a channel change script with some very basic
> > locking code in it. It doesn't handle race conditions, but should
> > work
> > pretty good (might fail once in a million times or something).
> > Here's
> > a copy:
> >
> > while [ -f $LOCKFILE ]
> > do
> > #echo "Waiting for lock..."
> >
> > sleep .1
> >
> > done
> >
> > touch $LOCKFILE
>
> I suggest you have a look at "flock" (man flock has a good simple
> overview). This provides a simple but foolproof locking mechanism
> using a file locked in exclusive mode.
>
> (
> flock -s 200
> # ... commands executed under lock ...
> ) 200>/path/to/mylockfile
Thanks, Mike, Ronald.
Your posts helped me fix my change channel scripts. Hopefully I'll have even
fewer channel change problems.
Mark
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.mythtv.org/pipermail/mythtv-users/attachments/20111024/25decba6/attachment.html
More information about the mythtv-users
mailing list