How to get Cron to send me email notifications

I just finished setting up Cron to backup my files to an external hard drive using Rsync and I would like Cron to send my an email message telling me that the job finished. I used the Task Scheduler to set everything up. I have entered my email address in the “Environment variables” and I have even set the variable “SEND_MAIL_ON_NO_ERROR” to yes in “/etc/sysconfig/cron”. For some reason I"m not receiving any emails. What is it that I’m missing here? How can I get this to work?

Hi
Have you checked root users mail to see if it arrived there?

Have you looked at the mail logs in /var/log to see if it got sent or
there is an error?

What email address did you use, <username>@localhost
should work.

I normally just write a backup script with all info/mails etc so if
it’s run by cron you only need to add when etc.


Cheers Malcolm °¿° (Linux Counter #276890)
openSUSE 11.0 x86 Kernel 2.6.25.18-0.1-default
up 3 days 9:50, 3 users, load average: 0.04, 0.06, 0.15
GPU GeForce 6600 TE/6200 TE - Driver Version: 177.80

I’ll check the file you suggested for any errors. The email address that I used was my personal address. I didn’t use the format that you suggested. Where do I check the root user mail at?

If I use <username>@localhost, will it arrive in Kmail?

Hi
Just open a konsole and su - to root user if there is mail you will
get a notification in the konsole session.

The mail should arrive (I use gnome) when you are in the console session just try a test email using the mail command;


mail -s "Test Email" malcolml@localhost
This is a test

..
EOT
exit

After your test text press enter twice and then the period “.” key

You can also re direct root users mail to a user by modifying
the /etc/aliases file and the running the command newaliases.


Cheers Malcolm °¿° (Linux Counter #276890)
openSUSE 11.0 x86 Kernel 2.6.25.18-0.1-default
up 3 days 17:13, 1 user, load average: 0.02, 0.01, 0.00
GPU GeForce 6600 TE/6200 TE - Driver Version: 177.80

I tried opening up a konsole and enter “su” and then my password and there weren’t any messages waiting for me. I also tried to send the test message and still nothing.

If I look in “/var/mail”, I can see that there is an email message there that says the connection to my personal email timed out. I wonder if I have to configure the email settings that are used by Cron somewhere, like having it use “smtp” to send. The message appears to be using “mx1”. Not sure what that is.

I’d prefer to just receive a message through Kmail instead of having to go into a Konsole to check. That’s why I entered my personal email address as an “Environment variable” in Cron.

Hi
Unless you have setup postfix to relay out through your isp it won’t be
sent.

Local mail should be delivered to your kmail inbox just by configuring
kmail to receive it (localmail).

The su command will not get to roots mail, the - command is important
as it setups roots environment including going to roots home directory
where any mail resides.

Try the test as yourself, then still at the console type in the command;


mail

You should have received a mail?


Cheers Malcolm °¿° (Linux Counter #276890)
openSUSE 11.0 x86 Kernel 2.6.25.18-0.1-default
up 1:13, 1 user, load average: 0.12, 0.33, 0.29
GPU GeForce 6600 TE/6200 TE - Driver Version: 177.80

I tried the test again, but not logged in as root this time. If I enter “mail” and go to the bottom of the messages, my new test message is there.

So you’re saying that if I configure Kmail to receive local messages this should show up there? Where in Kmail do I configure this? I didn’t see anything.

I also see this when I use the command “mail”

This is the mail system at host linux-4ezw.site.

I'm sorry to have to inform you that your message could not
be delivered to one or more recipients. It's attached below.

For further assistance, please send mail to postmaster.

If you do so, please include this problem report. You can
delete your own text from the attached returned message.

* * * * * * * * * *The mail system

<gumper@local.host>: Host or domain name not found. Name service error for
* * name=local.host type=AAAA: Host not found

And my test message is below that.

Hi
You just need to add a new account to kmail using localmail. I would
also configure via YaST-> Security and Users-> User and Group
Management and edit your username to receive system mail.


Cheers Malcolm °¿° (Linux Counter #276890)
openSUSE 11.0 x86 Kernel 2.6.25.18-0.1-default
up 2:09, 1 user, load average: 0.14, 0.13, 0.16
GPU GeForce 6600 TE/6200 TE - Driver Version: 177.80

Ok so now I can receive the messages in Kmail that I sent from the Konsole. I no longer receive the “message could not be delivered” either. The problem was that I was using “gumper@local.host” instead of replacing “local.host” with the actual host name. lol!
My bad!

Now I’ll have to see if cron will send me something.
Thanks for all the help. Hopefully you won’t hear from me again about this. :slight_smile:

When I ask KMail to read local inbox, it offers me to read $HOME/inbox. It should be checking $MAIL instead.