Mail not sending in Crontab

TheGuy

Expert Member
Joined
Sep 14, 2009
Messages
2,974
Reaction score
19
Location
Jozi
Hi Guys

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

#Add mail recipients here - comma seperated : [email protected],[email protected]
[email protected]

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?
 
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 ?
 
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.
 
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:
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.
 
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.
 
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.
 
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...
 
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.
 
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 [email protected]
I use it extensively where I dont want to setup a mailserver on an arb server but still want certain things mailed to me.
 
Ok I've managed to find a file in skel/.muttrc but it doesn't contain any mail server settings
 
It is a good idea to specify the PATH variable for scripts that are run from cron.
 
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:
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
Sign up to the MyBroadband newsletter
X