Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
HOWTO: send emerge job output via email
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks
View previous topic :: View next topic  
Author Message
hobo2
Tux's lil' helper
Tux's lil' helper


Joined: 08 May 2005
Posts: 87
Location: San Diego, CA & Miami, FL

PostPosted: Fri May 13, 2005 4:06 pm    Post subject: HOWTO: send emerge job output via email Reply with quote

I will document what works and what does not work, hopefully someone will complete a couple missing pieces

In principle, the steps below work with anything you schedule with cron, in case it makes a difference, I emerged fcron (not dcron, not vixie-cron) and the steps may be specific to fcron

all directions below assume setups as root and testing as root

As an example, I chose the command:
emerge --update world 2>&1 | tee -a /tmp/xxx.log

when I ran it initially, this was immediately after installing gentoo-r6 the output in /var/log/messages was:
May 10 23:50:00 gt6 fcron[7736]: Job xxx /tmp/xxx.log started for user cron (pid 7737)
May 10 23:50:00 gt6 fcron[7736]: Job xxx /tmp/xxx.log terminated (exit status: 1) (mailing output)
May 10 23:50:00 gt6 sSMTP[7736]: Unable to locate mail
May 10 23:50:00 gt6 sSMTP[7736]: Cannot open mail:25

ok, the problem was that sSMTP was not configured, so I edited /etc/ssmtp/ssmtp.conf and fixed the mailhost:
mailhost=mail.mydomain.com:2525

(I used my real domain address as I have my own email server)

next fcron job output in /var/log/messages:
May 11 09:12:16 g6 sSMTP[10181]: standardize() -- Buffer overflow

a partial solution was posted at https://forums.gentoo.org/viewtopic-p-2405996.html

emerge mailwrapper (v0.2)
edit etc/mail/mailer.conf like this:

# $OpenBSD: mailer.conf,v 1.3 2000/04/06 18:24:19 millert Exp $
#
# Execute the "real" sendmail program from ssmtp,
# named /usr/sbin/ssmtp
#
sendmail /usr/sbin/ssmtp -au USER -ap PASSWORD
send-mail /usr/sbin/ssmtp -au USER -ap PASSWORD
mailq /usr/sbin/ssmtp
newaliases /usr/sbin/ssmtp

(you would of course use the real email address and password, like "joe@google.com" and "fluffy12X")

when fcron runs, it automatically creates a log (/tmp/xxx.log) and emails the output
well, not so fast!

it emails the header like:
Output of fcron job: 'emerge --update world 2>&1 | tee -a /tmp/xxx.log Status code:1'

but! it does not email the /tmp/xxx.log

someone suggested to add the sendmail (alias sSMTP) command to the original fcron command, like:

emerge --update world 2>&1 | tee -a /tmp/xxx.log | /usr/lib/sendmail -ffcron@gentoo joe@google.com

still, only the header arrives via email, telling me the job ran and the status code in the subject, but no log is included in the email

it appears that with fcron and sendmail, these two command are identical insofar as results are concerned:

emerge --update world 2>&1 | tee -a /tmp/xxx.log
emerge --update world 2>&1 | tee -a /tmp/xxx.log | /usr/lib/sendmail -ffcron@gentoo joe@google.com

both produce only the header in the subject of the email that I receive

anyone care to complete the story and tell me how to get also the /tmp/xxx.log ?
Back to top
View user's profile Send private message
MKA
n00b
n00b


Joined: 20 May 2005
Posts: 9
Location: Europe/Finland

PostPosted: Fri May 20, 2005 11:10 am    Post subject: Reply with quote

Cron automatically sends the output of the commands in crontab to the user as mail (at least vixie-cron does), no need to specify extra commands to send that, unless You need something else sent as well.

You only need to fix sSMTP to get it work (can't help with that, I've only figured out postfix). However, short lookup does seem to tell that sSMTP can't handle that, so you might want to look at some better MTAs.
_________________
M.A.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum