Weekly cron job fails with fixes/30 on Debian 10

Have a MythTV related problem? Ask for help from other MythTV users here.

Moderator: Forum Moderators

Post Reply
gpw928
Junior
Posts: 19
Joined: Tue Feb 12, 2019 5:59 am
Location: Rural NSW
Australia

Weekly cron job fails with fixes/30 on Debian 10

Post by gpw928 » Fri Mar 20, 2020 9:26 pm

Hi,

I have recently upgraded to Debian 10 with MythTV from source fixes/30, and just got this in the mail:

Code: Select all

Message 318/318 Anacron <...my.domain>     Mar 21, 2020 07:47:52 am +1100
Date: Sat, 21 Mar 2020 07:47:52 +1100
To: root@mith.my.domain
Subject: Anacron job 'cron.weekly' on mith

/etc/cron.weekly/mythtv-database:
/etc/cron.weekly/mythtv-database: 17: /etc/cron.weekly/mythtv-database: USER: parameter not set
run-parts: /etc/cron.weekly/mythtv-database exited with return code 2
A quick look at /etc/cron.weekly/mythtv-database:

Code: Select all

line  7: set -e -u
line 17: if [ "$USER" = "" ]; then
The "set -e" is triggering the error exit when $USER is not set. I made the following change:

Code: Select all

line 17: if [ "X$USER" = "X" ]; then
Another option would be to add a USER definition to /etc/default/mythtv-backend.
Not sure which is best, nor how to log a bug report.
Last edited by gpw928 on Sat Mar 21, 2020 9:29 pm, edited 2 times in total.

wesnewell
Senior
Posts: 550
Joined: Mon Jun 23, 2014 6:54 pm
Location: Wylie TX, USA
United States of America

Re: Weekly cron job fails with fixes/30 on Debian 10

Post by wesnewell » Sat Mar 21, 2020 12:23 am

I ran into this a while back, and simply commenedt out the if user check since cron jobs are always run as root.
#!/bin/sh
# /etc/cron.weekly/mythtv-database script - check and backup mythconverg tables
# Copyright 2005/12/02 2006/10/08 Paul Andreassen
# 2010 Mario Limonciello
set -e -u
DBNAME="mythconverg"
DEBIAN="--defaults-extra-file=/etc/mysql/debian.cnf"
/usr/bin/mysqlcheck $DEBIAN -s $DBNAME
if [ -e "/etc/default/mythtv-backend" ]; then
. /etc/default/mythtv-backend
fi
# if [ "$USER" = "" ]; then
CMDPREFIX=""
# else
# CMDPREFIX="sudo -u $USER"
# fi
$CMDPREFIX /usr/share/mythtv/mythconverg_backup.pl
/usr/bin/logger -p daemon.info -i -t${0##*/} "$DBNAME checked and backed up."
# End of file.
BE/FE-Asrock AB350 Pro AMD Ryzen 3 2200G, 6 atsc tuners. Frontends-GF8200's,,AMD Athlon II's. Mythtv user since 2005.

User avatar
bill6502
Developer
Posts: 1463
Joined: Fri Feb 07, 2014 5:28 pm
United States of America

Re: Weekly cron job fails with fixes/30 on Debian 10

Post by bill6502 » Sat Mar 21, 2020 1:08 am

The packaging tree for Debian is here: https://github.com/MythTV/packaging/blo ... ron.weekly
And @gpw928 was just pushed for v30, v31 and master. Thanks for spotting the issue.

gpw928
Junior
Posts: 19
Joined: Tue Feb 12, 2019 5:59 am
Location: Rural NSW
Australia

Re: Weekly cron job fails with fixes/30 on Debian 10

Post by gpw928 » Sat Mar 21, 2020 9:40 pm

Thank you for that.

I just realised that I tested the change interactively, and that invalidated the testing ("dash -e" works differently when interactive).

The correct fix requires the failing command to explicitly tested, so lines 17 through 21 need to be replaced with this:

Code: Select all

CMDPREFIX=""
[ "X$USER" != "X" ] && CMDPREFIX="sudo -u $USER"

wesnewell
Senior
Posts: 550
Joined: Mon Jun 23, 2014 6:54 pm
Location: Wylie TX, USA
United States of America

Re: Weekly cron job fails with fixes/30 on Debian 10

Post by wesnewell » Sun Mar 22, 2020 12:37 am

Went through this a year ago.
viewtopic.php?f=36&t=3110
BE/FE-Asrock AB350 Pro AMD Ryzen 3 2200G, 6 atsc tuners. Frontends-GF8200's,,AMD Athlon II's. Mythtv user since 2005.

gpw928
Junior
Posts: 19
Joined: Tue Feb 12, 2019 5:59 am
Location: Rural NSW
Australia

Re: Weekly cron job fails with fixes/30 on Debian 10

Post by gpw928 » Sun Mar 22, 2020 1:02 am

My goal is to get the sources patched correctly so we won't have to go through it again.

User avatar
paulh
Developer
Posts: 471
Joined: Thu Feb 06, 2014 6:09 pm
Great Britain

Re: Weekly cron job fails with fixes/30 on Debian 10

Post by paulh » Sun Mar 22, 2020 11:02 am

I'm being lazy an can't be bothered to check the commits :roll: but I have a vague recollection of fixing this already maybe the changes weren't backported to fixes/30?

Post Reply