Hello - I was wondering if anyone has any advice on cron. I’ve been using a “user cron job” to run two scripts daily, and a “root cron job” to shut down the computer after the scripts run. It has worked well for months and I could check the output in /var/mail/user. Then, suddenly, a couple of weeks ago, the user cron job stopped sending emails with STDIO/STDERR outputs to the user. (in /var/mail/user dir) I haven’t been able to find this exact problem on the interwebs, and I need to fix this before I can start troubleshooting one of the scripts. The cron daemon seems to be running as at least one of the scripts is running, but another one is not, and I can’t troubleshoot without the outputs I used to find in /var/mail/user.
(This is a single system with only one user - /etc/crontab wasn’t edited so apparently that’s the ‘MAILTO=’ that’s always been there.)
(should SHELL=/bin/bash ?)
/etc/crontab
SHELL=/bin/sh
PATH=/usr/bin:/usr/sbin:/sbin:/bin:/usr/lib/news/bin
MAILTO=root
#
# check scripts in cron.hourly, cron.daily, cron.weekly, and cron.monthly
#
-*/15 * * * * root test -x /usr/lib/cron/run-crons && /usr/lib/cron/run-crons >/dev/null 2>&1
● postfix.service - Postfix Mail Transport Agent
Loaded: loaded (/usr/lib/systemd/system/postfix.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Sun 2021-04-11 08:36:59 MST; 1min 45s ago
Process: 1929 ExecStopPost=/etc/postfix/system/cond_slp deregister (code=exited, status=0/SUCCESS)
Process: 1850 ExecStart=/usr/sbin/postfix start (code=exited, status=1/FAILURE)
Tried starting and status…
● postfix.service - Postfix Mail Transport Agent
Loaded: loaded (/usr/lib/systemd/system/postfix.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Sun 2021-04-11 08:36:59 MST; 7min ago
Apr 11 08:36:57 linux-8e6p systemd[1]: Starting Postfix Mail Transport Agent...
Apr 11 08:36:57 linux-8e6p echo[1829]: Starting mail service (Postfix)
Apr 11 08:36:57 linux-8e6p postfix[1850]: fatal: parameter inet_interfaces: no local interface found for ::1
Apr 11 08:36:58 linux-8e6p systemd[1]: postfix.service: Control process exited, code=exited status=1
Apr 11 08:36:58 linux-8e6p cond_slp[1929]: /usr/sbin/postconf: fatal: parameter inet_interfaces: no local interface found for ::1
Apr 11 08:36:59 linux-8e6p systemd[1]: Failed to start Postfix Mail Transport Agent.
Apr 11 08:36:59 linux-8e6p systemd[1]: postfix.service: Unit entered failed state.
Apr 11 08:36:59 linux-8e6p systemd[1]: postfix.service: Failed with result 'exit-code'.
Let me see if I can get postfix running again… that reference to ::1 troubles me - it seems to be present in /etc/hosts.
EDIT: OK, I looked in /etc/hosts and the reference to the IP6 thingie “::1” was there. Then on a hunch I opened YaST/wicked and saw that the “Enable IP6” checkbox in Global Settings was unchecked. So I figure I must have unchecked that… So I checked it and rebooted. Now Postfix gets enabled without error upon reboot. That “may” solve the problem. Thank you for suggesting Postfix - I never would have guessed.
OK - just checking the “Enable IP6” option in YaST solved the problem. Thank you!! (Is there a problem with having IP6 enabled?)
Now I just have to figure out why the FTP connection to the cloud server is so flaky. About 1/3rd of the time, mput just times out. So I usually have to run the FTP upload script a few of times to make sure the cron FTP transfer finishes.
So I hear you saying to uncheck “Enable IP6” box in YaST Global Options, and to set
inet_protocols = ipv4
… in postfix (right now inet_protocols is commented-out in that config file). So I take this to mean IPv6 might be a security hole.
The data aren’t sensitive - my security concerns are the plaintext FTP password might assist someone in attacking the server/webpage or other such. I believe they do support standard SFTP, but it was pretty tricky to find an FTP mput script recommendation online (that I could understand). I haven’t been able to find an sftp script, so that’s sort of an ongoing project.
I’ve been using a sort of standard format…
… there seem to be a dizzying array of options, SFTP, FTPS, LFTP, … then, deeper things like use of SSH, TLS, etc. I’m really only concerned about the plaintext FTP password (although I am no security expert!).
Hi
I would recommend sftp if that works, can you use your ssh key instead of a password?
#!/usr/bin/perl
use Net::SFTP::Foreign;
# perl-Net-SFTP-Foreign-1.93-lp151.1.1.noarch.rpm
# from https://download.opensuse.org/repositories/devel:/languages:/perl/openSUSE_Leap_15.1/noarch/
use warnings;
use strict;
my $host = "ftp.email.add";
my $sftp = Net::SFTP::Foreign->new($host, user => 'email@email.add, password => '24398868');
$sftp->error and die "Something bad happened: " . $sftp->error;
$sftp->put("RH.webm", "RH.webm") or die "put failed: " . $sftp->error;
$sftp->put("SWDOWNA.webm", "SWDOWNA.webm") or die "put failed: " . $sftp->error;
Hmmm… I hadn’t even thought of trying to use Perl. I guess I thought the ftp tool would be representative of modern linux robustness. OK, thanks. I’ll check out that code. I’m really not sure where the problem is. I have sometimes-slow internet, but I though mput dealt with all that. (it hangs up during one of the mput’s) That looks like paid software - I guess default linux software isn’t very usable. I couldn’t find good examples of bash scripting ftp and fail-detect/retry.
Well, calling a Python script that used Python’s ftplib to do the uploading worked. I guess their ftplib has built-in code to deal with spotty connections. I don’t know why such a thing didnt’ occur to me. Perl was also an idea - thanks for suggesting that - but I have never worked with Perl and it looks difficult. But it seems worth learning. (Maybe Padre or Eclipse/EPIC would make learning to do things in Perl easier.) Perl Maven has lots of stuff. I remember the linux guys in the 80’s talking about Perl as something you needed to know.
“[Perl] was initially designed to replace complex shell scripts.”
The “Programming Perl” book – really a reference guide – takes some time to digest – 1070 pages …
ISBN: 978-0-5960049-2-7 – O’Reilly.
To understand the difference between Perl 4 and 5 and, where Perl 6 went «Raku» and, the upcoming Perl 6, take a look at the Wikipedia page – https://en.wikipedia.org/wiki/Perl.