[mythtv-users] stagger start times for simultaneous recordings?
mythtv at mikeholden.org
Sun Oct 23 10:21:03 UTC 2011
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
> pretty good (might fail once in a million times or something).
> a copy:
> while [ -f $LOCKFILE ]
> #echo "Waiting for lock..."
> sleep .1
> 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 ...
More information about the mythtv-users