[mythtv-users] Delayed User Job

f-myth-users at media.mit.edu f-myth-users at media.mit.edu
Sat Mar 3 06:51:26 UTC 2007


    > Date: Fri, 2 Mar 2007 10:56:55 -0500
    > From: Rod Smith <mythtv at rodsbooks.com>

    > Unless I'm missing something, the above should do the trick. Of course, stated 
    > in this broad a fashion it sounds pretty easy (assuming you know a suitable 
    > scripting language), but managing that queue of shows (in steps #1 and #2) is 
    > likely to be a pain if you attempt to do it "from scratch." There are 
    > probably existing tools that would help manage the queue, but I don't know 
    > offhand what they might be.

See http://cvs.mythtv.org/trac/changeset/12917; cpinkham has obviously
been following this thread and just checked in some infrastructure
(but not a complete solution yet).

As for your queue-management, we'll presume that the OP would only be
running one instance of this thing at a time (hence no need for
locking), and the trivial way to do this is with a shell script that's
calling "head -1" to grab the first line in the file, and then rewrite
a new copy of the file using "tail +2" (the + arg to tail is buried in
its manpage and easy to miss, and the 2 is to compensate for the
0-origin of head and the 1-origin of tail, essentially).  Adding tasks
at the end with >> keeps this going in FIFO order.

But now that I've written that, it's probably easier to just have a
script that calls "find" with suitable args to get anything older than
a certain amount, pipe that through "head -1" to pick off the first
one, and then just process that.  When you're dong with that one,
iterate.  Now you don't have to worry about managing any sort of queue
yourself, because the filesystem -is- your queue, including not having
to remember that something got deleted (if it did, "find won't find it :).
If you don't find anything to work on, sleep for an hour and then
iterate again.  This seems like it'd be about 5 lines of some shell
script:  an infinite while loop enclosing the find|head, a conditional,
the actual work, and the sleep.


More information about the mythtv-users mailing list