I have a script I run to determine my DSL modem’s IP address. For several
years it has run w/o issues. All it does is make a few calls to determine
the current IP address. It then compares that to the last assigned IP. If
it changes, the change is logged and the new address is posted as an email
to my hosting site. Think of it as a cheapskate’s dyndns.
This worked for years but I made 2 major changes to the system recently and
now it is erratic. The first replaced a dead/dying machine with a new Core
I7 box. Went from an AMD Athlon X2 @ 1800 Mhz to 8 cores @3600 Mhz and 4GB
of RAM to 12 GB - over kill, but nice to have. The second was to update to
12.3 from 11.4 - which went well with only a couple of minor glitches.
The problem is that the cron script is behaving in strange ways now.
Typically, the first time it runs and sees a change in IP after a cold boot,
everything goes as expected - change is logged and an email sent.
Thereafter, it detects a change and logs it but will only post the email
about every tenth time. That defeats the whole purpose of the script. The
cron job also posts no local mail the way it did under 11.4 but I see that
there have been some changes to the cron process so that I think I can work
out. What I can’t figure out is where the script is bombing out and failing
to send the email. I can understand failing to pass the email via mailx
every time and never is also a straight forward debug problem but this
“maybe” stuff has me somewhat befuddled. 12.3 has moved logs all over the
place and I can’t even find where the attempt to send is logged.
What do you want to debug first? Because I’m a bit lost.
If you want to track the local emails that cron sends to the user on
error, the log is /var/log/mail, as always. mailx does not intervene
here. The mail is sent to the user that owns the cron job, or to the one
named in the variable “MAILTO=” at the start of the cron file.
–
Cheers / Saludos,
Carlos E. R.
(from 12.3 x86_64 “Dartmouth” at Telcontar)
> On 2013-07-29 17:56, Will Honea wrote:
>
>> Any thoughts on where to go with this?
>
> What do you want to debug first? Because I’m a bit lost.
>
Wasn’t sure where to start, myself.
> If you want to track the local emails that cron sends to the user on
> error, the log is /var/log/mail, as always. mailx does not intervene
> here. The mail is sent to the user that owns the cron job, or to the one
> named in the variable “MAILTO=” at the start of the cron file.
>
That was the piece I was missing. I found that any message logged there was
in fact sent to the smtp server and showed up in the email stream while the
ones that were missing were also missing this log. Best I can guess, I’m
messing up the call to mailx and the the emails are, in fact, not being
sent. The man docs mention several changes to both mailx and the cron
process for 12.3 so I need to start there and see just what has changed
between that and 11.4.
On 2013-07-30 06:47, Will Honea wrote:
> Carlos E. R. wrote:
> That was the piece I was missing. I found that any message logged there was
> in fact sent to the smtp server and showed up in the email stream while the
> ones that were missing were also missing this log. Best I can guess, I’m
> messing up the call to mailx and the the emails are, in fact, not being
> sent. The man docs mention several changes to both mailx and the cron
> process for 12.3 so I need to start there and see just what has changed
> between that and 11.4.
Forget mailx. Cron does not use mailx, it uses “sendmail”, since the
beginning of time.
Unless you have changed it…
-m This option allows you to specify a shell command
to use for sending Cron mail output instead of
using sendmail(8) This command must accept a
fully formatted mail message (with headers) on
standard input and send it as a mail message to
the recipients specified in the mail headers.
Specifying the string off (i.e. crond -m off)
will disable the sending of mail.
Are you using that?
We are talking only of the local mails that cron sends to root on error,
not of the emails sent to you with the IP.
–
Cheers / Saludos,
Carlos E. R.
(from 12.3 x86_64 “Dartmouth” at Telcontar)
> Forget mailx. Cron does not use mailx, it uses “sendmail”, since the
> beginning of time.
>
Comments well taken. Guess it’s time to start over and do this right - heck
I might even RTFM!
Actually, I’m more at home debugging C/C++ code but I have not even done
much of that on Linux - or any platform - for several years now. I guess I
need to keep up, even in retirement.
On 2013-07-31 06:33, Will Honea wrote:
> Carlos E. R. wrote:
>
>> Forget mailx. Cron does not use mailx, it uses “sendmail”, since the
>> beginning of time.
>>
>
> Comments well taken. Guess it’s time to start over and do this right - heck
> I might even RTFM!
You have to differentiate between the internal mail cron sends on error
to a local user, and the mails that job sends to you. The first kind are
done with “sendmail” (even postfix contains a small sendmail program for
compatibility with system code using that method). The second kind is up
to you, and mailx is a very good one.
> Actually, I’m more at home debugging C/C++ code but I have not even done
> much of that on Linux - or any platform - for several years now. I guess I
> need to keep up, even in retirement.
Yes, if I had to code in C again it would take me weeks or months to get
up to speed again.
–
Cheers / Saludos,
Carlos E. R.
(from 12.3 x86_64 “Dartmouth” at Telcontar)
> I have a script I run to determine my DSL modem’s IP address. For several
> years it has run w/o issues. All it does is make a few calls to determine
> the current IP address. It then compares that to the last assigned IP.
> If it changes, the change is logged and the new address is posted as an
> email
> to my hosting site. Think of it as a cheapskate’s dyndns.
>
> This worked for years but I made 2 major changes to the system recently
> and
> now it is erratic. The first replaced a dead/dying machine with a new
> Core
> I7 box. Went from an AMD Athlon X2 @ 1800 Mhz to 8 cores @3600 Mhz and
> 4GB of RAM to 12 GB - over kill, but nice to have. The second was to
> update to 12.3 from 11.4 - which went well with only a couple of minor
> glitches.
>
> The problem is that the cron script is behaving in strange ways now.
> Typically, the first time it runs and sees a change in IP after a cold
> boot, everything goes as expected - change is logged and an email sent.
> Thereafter, it detects a change and logs it but will only post the email
> about every tenth time. That defeats the whole purpose of the script. The
> cron job also posts no local mail the way it did under 11.4 but I see that
> there have been some changes to the cron process so that I think I can
> work
> out. What I can’t figure out is where the script is bombing out and
> failing
> to send the email. I can understand failing to pass the email via mailx
> every time and never is also a straight forward debug problem but this
> “maybe” stuff has me somewhat befuddled. 12.3 has moved logs all over the
> place and I can’t even find where the attempt to send is logged.
>
> Any thoughts on where to go with this?
>
To finish this off, stepping through the script revealed that it was timing
out waiting for a reply from the ISP during login. For years, they had the
TLS port set to 537 but quietly removed the port 537 access and moved the
TLS path to port 25 - the default smtp port. Removing the port spec from
the smtp address fixed everything.