Mail not sending in Crontab

TheGuy

Expert Member
Joined
Sep 14, 2009
Messages
2,971
Hi Guys

I have a script running that is suppose to email me the backup results:

#Add mail recipients here - comma seperated : MAILTO=xyz@somewhere.com,abc@somewhere.com
MAILTO=me@mycompany.local

tar cvf /dev/st0 / 2>/local/root_backuplog.err >/local/root_backuplog
mt -f /dev/st0 offline

tail -n 15 /local/root_backuplog | mutt -x -a /local/root_backuplog.err -s "Daily backup logs" $MAILTO

/local/removetmp
/sbin/shutdown -g0 -y -i6

Can you see if I'm doing anything wrong as the email is not coming through?
 

Murlin

Active Member
Joined
Dec 11, 2008
Messages
69
Maillog

I see you are using "mutt" to send a mail. Can you see anything in the maillogs ? Have you run the command manually to see if the box can run the command ?
 

hedgehog

Well-Known Member
Joined
Jan 3, 2008
Messages
152
I had a problem yesterday where the path wasn't setup correctly from a script executed by cron, simply solved by using absolute paths on all the commands.
 

TheGuy

Expert Member
Joined
Sep 14, 2009
Messages
2,971
I see you are using "mutt" to send a mail. Can you see anything in the maillogs ? Have you run the command manually to see if the box can run the command ?

Not sure how to check the mail logs but I ran the command manually and the server restarted afterwards so I think it's working.


I had a problem yesterday where the path wasn't setup correctly from a script executed by cron, simply solved by using absolute paths on all the commands.

The script was working before and I haven't changed anything. Were can I check what relay server the Mail to uses? I suspect the problem started after replacing the Mail server?
 
Last edited:

rward

Senior Member
Joined
Oct 26, 2007
Messages
865
yeah - absolute paths all the time. To find out where the program is use 'which':
which tail
/usr/bin/tail


mail logs should be in /var/log/mail.log or /var/log/maillog

you should be able to see where it's trying to send/relay through from there.
also check your spam folder of the receiver in case it's getting flagged as spam.
also check the /var/spool/mail/ to make sure the mail isn't being bounced back to where it's being sent from.
 

TheGuy

Expert Member
Joined
Sep 14, 2009
Messages
2,971
mail logs should be in /var/log/mail.log or /var/log/maillog

No mail logs in there. There is logs but it doesn't contain anything about logs.

you should be able to see where it's trying to send/relay through from there.
also check your spam folder of the receiver in case it's getting flagged as spam.

Checked it no email in spam folder

also check the /var/spool/mail/ to make sure the mail isn't being bounced back to where it's being sent from.

This directory is empty.
 

MickZA

Executive Member
Joined
Jan 19, 2007
Messages
7,575
If it failed after replacing the mail server check your smtp setting(s) in Muttrc.
 

TheGuy

Expert Member
Joined
Sep 14, 2009
Messages
2,971
If it failed after replacing the mail server check your smtp setting(s) in Muttrc.

Sorry where is the file located? Not really a Linux admin but I can't get our idiot Linux guy which charges R1600 and hour out to come and fix it.
 

MickZA

Executive Member
Joined
Jan 19, 2007
Messages
7,575
From your script you should be calling the default system wide config - /etc/Muttrc
 

Kasyx

Expert Member
Joined
Jun 6, 2006
Messages
2,565
Sorry where is the file located? Not really a Linux admin but I can't get our idiot Linux guy which charges R1600 and hour out to come and fix it.

R1600?!

And all this time I have been under-charging...
 

MickZA

Executive Member
Joined
Jan 19, 2007
Messages
7,575
Not my area of expertise but if it worked before mutt must be installed, to check:

from the command line zypper se mutt will show packages that support mutt, an i indicates it is installed.
 

Rocket-Boy

Honorary Master
Joined
Jul 31, 2007
Messages
10,199
or you could save yourself the hassle and install a package called "email" yes its a stupid name but it works. It allows you to use external SMTP's without relayhosts etc.
The syntax would be: email -s "Daily backup logs" -a /path/to/attachment person@company.com
I use it extensively where I dont want to setup a mailserver on an arb server but still want certain things mailed to me.
 

TheGuy

Expert Member
Joined
Sep 14, 2009
Messages
2,971
Ok I've managed to find a file in skel/.muttrc but it doesn't contain any mail server settings
 

Nod

Honorary Master
Joined
Jul 22, 2005
Messages
10,057
It is a good idea to specify the PATH variable for scripts that are run from cron.
 

Nod

Honorary Master
Joined
Jul 22, 2005
Messages
10,057
Ok I've managed to find a file in skel/.muttrc but it doesn't contain any mail server settings

That normally gets copied to you home directory when you create a user.
Try `cat ~/.muttrc`
If that is empty, or does not exist, you might have to create a new one with the needed information.

On my laptop, I use exim to send mail via my ISP. Works very well.
Some info here: http://newbiedoc.sourceforge.net/networking/exim.html
 
Last edited:

MickZA

Executive Member
Joined
Jan 19, 2007
Messages
7,575
One result from googling "suse default mutt":

if you don't have your own .muttrc mutt will use the system version, found at
/etc/Muttrc (note the capital M). So,

Suggestion #2 is to copy /etc/Muttrc to your home directory (~/.muttrc) and
edit the bejeezus out of it. Lastly, sounds like you could use a good
beginner's guide to mutt. Here, have mine:
http://therandymon.com/content/view/42/98/ (HTML and PDF versions).

Please confirm that script you posted ran successfully in the past.
 
Last edited:
Top