LinHES Forums
http://forums.linhes.org/

Problem with running mythfilldatabase automatically
http://forums.linhes.org/viewtopic.php?f=6&t=2365
Page 1 of 1

Author:  nbdwt73 [ Thu Sep 09, 2004 6:19 am ]
Post subject:  Problem with running mythfilldatabase automatically

I am running a fresh install of 15.1 and am having a problem with mythfilldatabase running as either a cron job (cron.daily) or built-in. When run from a command line (either as root or mythtv) it works fine.

As an experiment I have set both a cron job and the built-in job... Cron.daily entry:

#!/bin/sh

su mythtv -c "mythfilldatabase --quiet"

I have searched the logs and can find only one clue. I have set the cron job to run at 5:25 and get the following in /var/log/auth.log

Sep 9 05:25:01 mythtv cron(pam_unix)[3741]: session opened for user root by (uid=0)
Sep 9 05:25:01 mythtv su[3764]: + ??? root-nobody
Sep 9 05:25:01 mythtv su(pam_unix)[3764]: session opened for user nobody by (uid=0)
Sep 9 05:30:01 mythtv cron(pam_unix)[4095]: session opened for user root by (uid=0)

That is the only reference in any of my logs to anything at 5:25.

I have the "built-in mythfilldatabase" scheduled to run between 7AM and 8AM. I can find no evidence that anything ran (no logs, no update to the schedule, and no status message).

I have run out of ideas...

Everything else runs perfectly.

Thanks

Author:  tjc [ Thu Sep 09, 2004 9:36 pm ]
Post subject: 

"Three things ye must know about the wisewoman..." Oh wait, wrong topic. ;-) Two things ye must know about the cron job...

- One of the best ways to debug a cron job is to put in lines like this:
Code:
echo "At start of myscript" >>/tmp/myscript.debug.$$.log

Put somthing like this near the beginning, another at the end, ... You get the picture. Don't forget to remove or comment them out when you're done debugging. Even more informative:
Code:
/usr/bin/env >>/tmp/myscript.debug.$$.log


- cron jobs run in stripped envionment, among other things that means that you don't have a full path, and shouldn't assume any. As a result you should always test a script intended for a cron job like this:
Code:
env -i myscript.sh

This will let you spot any unwarranted assumptions about your environment.

So given this, the bug in your script should be obvious, replacing:
Code:
su mythtv -c "mythfilldatabase --quiet"

with this:
Code:
/bin/su mythtv -c "/usr/bin/mythfilldatabase --quiet"

should solve your problem.

Page 1 of 1 All times are UTC - 6 hours
Powered by phpBB® Forum Software © phpBB Group
http://www.phpbb.com/