[mythtv-users] finish current job and shutdown?

Thomas Boehm mythtv-users at lists.boehmi.net
Mon Nov 14 16:49:40 UTC 2011


Jeremy Jones wrote:
> On Sun, Nov 13, 2011 at 1:07 PM, Thomas Boehm wrote:
>     Now I want the backend not to wait until all jobs have finished. I'd
>     rather have it finish the currently running job and shutdown and
>     continue the job queue the next time it wakes up.

> I posted a similar question a few days ago.  See this
> thread: http://www.gossamer-threads.com/lists/mythtv/users/496572
> I haven't followed up on my question/solution yet, but there are some
> things in Mike Dean's Post that may also help you.

Hi Jeremy,

I remember, reading your post, but not the followups. So the short
answer is no according to Dean.

I kind of solved it for now. My user job in Myth looks now like this

echo "/usr/bin/nice -n 19 /usr/local/bin/handbrake_userjob.sh
%DIR%/%FILE% /home/mythtv/Videos/TV/ %CHANID% %STARTTIME%" >>
~/.mythtv/jobqueue

Then I wrote a script which runs when the mythtv user logs in

-----------
#!/bin/bash
while true
do
  COMMAND=`head -n 1 ~/.mythtv/jobqueue`
  $COMMAND
  ERROR=$?
  sed -i 1d ~/.mythtv/jobqueue
  if [ $ERROR -gt 0 ]
  then
    echo "userjob $COMMAND unsuccessful"|mail your.em at il.address
  fi
sleep 180
done
-----------

This takes the first line of the file, executes it and deletes that
line. If there is a problem with the userjob I'll get an email about it.
The sleep value should be greater than the "idle shutdown timeout",
otherwise the backend will never shutdown as long as there are jobs in
~/.mythtv/jobqueue.

You'll also need your own "Pre-shutdown-check command" which checks
whether a userjob is running or not. Something like

...
pidof -x handbrake_userjob.sh || ERROR=1
mythshutdown --check || ERROR=1
...
exit $ERROR

would do.

The downside is that I don't see the running userjob in mythweb or
mythtvfrontend. I couldn't find a way to add a userjob to Myth from the
command line. I searched the database and didn't se any references of
running/queued jobs in it, only completed ones.

bye
Thomas


More information about the mythtv-users mailing list