[mythtv-users] anacron

Stephen Worthington stephen_agent at jsw.gen.nz
Sat May 4 04:26:05 UTC 2019


On Fri, 3 May 2019 18:48:33 -0400, you wrote:

>daryl at trieli:~$ cat /var/log/syslog | grep anacron
>May  2 19:35:52 trieli anacron[6305]: Job `cron.daily' terminated
>May  2 19:35:52 trieli anacron[6305]: Normal exit (1 job run)
>May  3 17:48:34 trieli systemd[1]: Started Trigger anacron at 19:30.
>
>Above proves the run time for anacron has been amended, but why only one
>job run? I've got lots of jobs in there:
>daryl at trieli:~$ ls -al /etc/cron.daily
>total 84
>drwxr-xr-x   2 root root  4096 Apr 25 22:45 .
>drwxr-xr-x 132 root root 12288 Apr 29 11:55 ..
>-rwxr-xr-x   1 root root   311 May 29  2017 0anacron
>-rwxr-xr-x   1 root root   376 Nov 20  2017 apport
>-rwxr-xr-x   1 root root  1478 Apr 20  2018 apt-compat
>-rwxr-xr-x   1 root root   355 Dec 29  2017 bsdmainutils
>-rwxr-xr-x   1 root root   384 Dec 12  2012 cracklib-runtime
>-rwxr-xr-x   1 root root  1176 Nov  2  2017 dpkg
>-rwxr-xr-x   1 root root   372 Aug 21  2017 logrotate
>-rwxr-xr-x   1 root root  1065 Apr  7  2018 man-db
>-rwxr-xr-x   1 root root   538 Mar  1  2018 mlocate
>-rwxr-xr-x   1 root root   449 Apr 14  2018 mythtv-database
>-rwxr-xr-x   1 root root  1387 Dec 13  2017 ntp
>-rwxr-xr-x   1 root root  1286 Jan 12 09:56 optimize_mythdb.pl
>-rwxr-xr-x   1 root root   249 Jan 25  2018 passwd
>-rw-r--r--   1 root root   102 Nov 16  2017 .placeholder
>-rwxr-xr-x   1 root root  3477 Feb 20  2018 popularity-contest
>-rwxr-xr-x   1 root root   246 Mar 21  2018 ubuntu-advantage-tools
>-rwxr-xr-x   1 root root   214 Jul 12  2013 update-notifier-common
>
>Is this as it should be?

Yes.

Anacron runs things from /etc/anacrontab.  This is what is in
anacrontab:

root at mypvr:/etc# cat /etc/anacrontab
# /etc/anacrontab: configuration file for anacron

# See anacron(8) and anacrontab(5) for details.

SHELL=/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
HOME=/root
LOGNAME=root

# These replace cron's entries
1       5       cron.daily      run-parts --report /etc/cron.daily
7       10      cron.weekly     run-parts --report /etc/cron.weekly
@monthly        15      cron.monthly    run-parts --report
/etc/cron.monthly

So the job that anacron runs is named "cron.daily".  The cron.daily
job runs the command "run-parts --report /etc/cron.daily".  So it runs
the "run-parts" program on the contents of the "/etc/cron.daily"
directory.  If you do a "man run-parts" command, you will see that
run-parts will read all the files in /etc/cron.daily and run them in
the order it reads them.  It will do it sequentially - one job will
not start until the previous one has finished.  The "--report" option
makes run-parts output the name of any job it runs that produces
output on stdout or stderr.  Anacron collects all the output from
run-parts and emails it to the user that anacron is running as (root
in this case).  If you do not have your system set up to do email,
that email will be dropped.  So you either need to install email
software on your system, or put a "MAILTO=myemail at myaddress" line at
the top of the /etc/anacrontab file to direct the email to one of your
existing accounts.  I have email software installed on my system, so
from a root command line I just run "mail" to see the daily email from
anacron (sudo mail should also work):

root at mypvr:~# mail
"/var/mail/root": 1 message 1 unread
>U   1 Anacron            Sat May  4 10:14 274/12062 Anacron job 'cron.daily' on mypvr
?

Then I hit enter to read the mail.  This is the top of it:

Return-Path: <root at mypvr.jsw.gen.nz>
X-Original-To: root
Delivered-To: root at mypvr.jsw.gen.nz
Received: by mypvr.jsw.gen.nz (Postfix, from userid 0)
        id C9954C21FF; Sat,  4 May 2019 10:14:42 +1200 (NZST)
From: Anacron <root at mypvr.jsw.gen.nz>
To: root at mypvr.jsw.gen.nz
Subject: Anacron job 'cron.daily' on mypvr
Content-Type: text/plain; charset=UTF-8
Message-Id: <20190503221442.C9954C21FF at mypvr.jsw.gen.nz>
Date: Sat,  4 May 2019 10:14:42 +1200 (NZST)
X-IMAPbase: 1556940568 2
Status: O
X-UID: 1

/etc/cron.daily/optimize_mythdb:
Repaired/Optimized: `mythconverg`.`archiveitems`
Analyzed: `mythconverg`.`archiveitems`
Repaired/Optimized: `mythconverg`.`bdbookmark`
Analyzed: `mythconverg`.`bdbookmark`
Repaired/Optimized: `mythconverg`.`callsignnetworkmap`
Analyzed: `mythconverg`.`callsignnetworkmap`
Repaired/Optimized: `mythconverg`.`capturecard`
Analyzed: `mythconverg`.`capturecard`
Repaired/Optimized: `mythconverg`.`cardinput`
Analyzed: `mythconverg`.`cardinput`
Repaired/Optimized: `mythconverg`.`channel`
Analyzed: `mythconverg`.`channel`

You can see the line "/etc/cron.daily/optimize_mythdb:" where
run-parts has added the name of the job it ran that produced the
output.  The --report option only adds that line when a job produces
output - if you want all the jobs that are run to be listed, change
"--report" to "--verbose".

To install email software to do what I do, you need to install the
"postfix" and "mailutils" packages:

apt install postfix mailutils

The "mail" command is linked to "mail.mailutils", so run "man
mail.mailutils" to find out how to run it.  If you just want to get
the emails sent to an existing account using the MAILTO option, you
may still need to install some email software in order to send the
emails - I am not sure about that.  So it would pay to just add the
MAILTO option and see if it works the next time anacron is run.  If it
does not, then you will likely need to install postfix (or some other
email package that provides the /usr/sbin/sendmail command) and
configure it to be able to send things.  I think the default settings
for postfix will work to send emails directly to the provider for the
email address, but if (like me) you need to send them via your ISP's
mail server in order for them not to be marked as SPAM, then you would
need to configure postfix to do that, likely with one line in
/etc/postfix/transportmaps like this:

* smtp:myispsmtpaddress.isp.com

Postfix is a full scale complex email program that can be used even by
ISPs to do email, so it has heaps of configuration options.  But the
only other thing I configured on it was its /etc/postfix/main.cf file:

root at mypvr:/etc/postfix# cat /etc/postfix/main.cf
# See /usr/share/postfix/main.cf.dist for a commented, more complete
version


# Debian specific:  Specifying a file name will cause the first
# line of that file to be used as the name.  The Debian default
# is /etc/mailname.
#myorigin = /etc/mailname

smtpd_banner = $myhostname ESMTP $mail_name (Ubuntu)
biff = no

# appending .domain is the MUA's job.
append_dot_mydomain = no

# Uncomment the next line to generate "delayed mail" warnings
#delay_warning_time = 4h

readme_directory = no

# TLS parameters
smtpd_tls_cert_file=/etc/ssl/certs/ssl-cert-snakeoil.pem
smtpd_tls_key_file=/etc/ssl/private/ssl-cert-snakeoil.key
smtpd_use_tls=yes
smtpd_tls_session_cache_database =
btree:${data_directory}/smtpd_scache
smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache

# See /usr/share/doc/postfix/TLS_README.gz in the postfix-doc package
for
# information on enabling SSL in the smtp client.

myhostname = mypvr.jsw.gen.nz
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
myorigin = /etc/mailname
mydestination = mypvr.jsw.gen.nz, mypvr, localhost.localdomain,
localhost, mypvr.6.jsw.gen.nz
relayhost = smtpg.jsw.gen.nz
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128 10.0.0.0/8
2406:e001:1:2800::/56
mailbox_size_limit = 0
recipient_delimiter = +
inet_interfaces = loopback-only

maximal_queue_lifetime = 30d
relay_recipient_maps =
relay_domains = jsw.gen.nz
transport_maps = hash:/etc/postfix/transportmaps
smtpd_recipient_restrictions = permit_mynetworks,
reject_unauth_destination

In that, look at the "myhostname", "mydestination", "relayhost",
"mynetworks", "relay_domains" and "inet_interfaces" options, which I
customised for my network.  The "relayhost" option is set to my own
SMTP server address, as I run my own SMTP server, but you would need
to set it to the same address as you put in the transportmaps file.
The rest of the changed settings control where emails are accepted
from on your network and where they can be sent to.  It is best to
limit access to postfix (and all email software), as it is a target
for spammers and malware if it is not configured to ignore outside
access.  So the most important one of those options is
"inet_interfaces = loopback-only" which means that postfix is only
accessible from the localhost interface of the machine it is running
on.  The rest of the options are just "belt and braces".


More information about the mythtv-users mailing list