LinuxQuestions.org
Register a domain and help support LQ
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices



Reply
 
Search this Thread
Old 10-03-2007, 08:54 PM   #1
thoron!
LQ Newbie
 
Registered: Jul 2007
Location: ohio
Distribution: Slackware, FreeBSD
Posts: 26

Rep: Reputation: 15
Email Logs Slackware 12


I want to be able to email myself from a cron job.

I have this set up using ssmtp on my router but I would like my web server box to do something similar.

Tutorials that I have went though don't seem to get me anywhere.

ssmtp was nice since I could use a gmail account to send messages from.
 
Old 10-04-2007, 01:11 AM   #2
Alien_Hominid
Senior Member
 
Registered: Oct 2005
Location: Lithuania
Distribution: Hybrid
Posts: 2,247

Rep: Reputation: 53
Can you elaborate more about your problem?
 
Old 10-04-2007, 02:00 AM   #3
thoron!
LQ Newbie
 
Registered: Jul 2007
Location: ohio
Distribution: Slackware, FreeBSD
Posts: 26

Original Poster
Rep: Reputation: 15
i think i basically need a script that will email me httpd logs or logs from /var/log that i can cron to send them at a certain time each day
 
Old 10-04-2007, 11:54 AM   #4
rworkman
Slackware Contributor
 
Registered: Oct 2004
Location: Tuscaloosa, Alabama (USA)
Distribution: Slackware
Posts: 1,971

Rep: Reputation: Disabled
Look into using mailx(1)
 
Old 10-06-2007, 11:34 AM   #5
pricejm
LQ Newbie
 
Registered: Aug 2005
Location: Charleston, SC.
Posts: 17

Rep: Reputation: 0
Hi,

I'm the guy thoron posted this for...

I've gotton this far:

Using mailx to use smtp.gmail.com, since I can't send mail directly to the gmail account (invalid ip address, would have to relay through isp smtp...).

mailx -v -s Test -S smtp-use-starttls -S smtp-auth=login -S smtp=smtp.gmail.com:587 -S from=fromEmail@gmail.com -S smtp-auth-user=user@gmail.com -S smtp-auth-password="password" toEmail@gmail.com

This results in:

Code:
Resolving host smtp.gmail.com . . . done.
Connecting to 64.233.185.111 . . . connected.
220 mx.google.com ESMTP g9sm5349298wra
>>> EHLO serverName.com
250-mx.google.com at your service, [68.58.162.123]
250-SIZE 28311552
250-8BITMIME
250-STARTTLS
250 ENHANCEDSTATUSCODES
>>> STARTTLS
220 2.0.0 Ready to start TLS
Error with certificate at depth: 0
 issuer = /C=ZA/ST=Western Cape/L=Cape Town/O=Thawte Consulting cc/OU=Certification Services Division/CN=Thawte Premium Server CA/emailAddress=premium-server@thawte.com
 subject = /C=US/ST=California/L=Mountain View/O=Google Inc/CN=smtp.gmail.com
 err 20: unable to get local issuer certificate
Continue (y/n)? could not initiate SSL/TLS connection: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed
"/home/pricejm/dead.letter" 11/315
. . . message not sent.
 
Old 10-06-2007, 11:44 AM   #6
pricejm
LQ Newbie
 
Registered: Aug 2005
Location: Charleston, SC.
Posts: 17

Rep: Reputation: 0
Ok I added "-S ssl-verify=ignore" and it went through.

Maybe I need to grab a cert and save it?

Now figuring that one out...

Last edited by pricejm; 10-06-2007 at 11:52 AM.
 
Old 10-06-2007, 01:33 PM   #7
pricejm
LQ Newbie
 
Registered: Aug 2005
Location: Charleston, SC.
Posts: 17

Rep: Reputation: 0
Thumbs up

This is what I concluded with:

Code:
#! /bin/sh

ACCESS_LOG=/var/log/httpd/access_log
ERROR_LOG=/var/log/httpd/error_log
SMTP=smtp.gmail.com:587
FROM_MAIL=fromMail@gmail.com
LOGIN=logIn@gmail.com
LOGIN_PASSWORD=password
TO_MAIL=toMail@gmail.com

#Email access log
SUBJECT='httpd Access Log'
cat $ACCESS_LOG | mailx $1 -s "$SUBJECT" -S ssl-verify=ignore -S smtp-use-starttls -S smtp-auth=login -S smtp="$SMTP" -S from="$FROM_MAIL" -S smtp-auth-user="$LOGIN" -S smtp-auth-password="$LOGIN_PASSWORD" $TO_MAIL

#Email error log
SUBJECT='httpd Error Log'
cat $ERROR_LOG | mailx $1 -s "$SUBJECT" -S ssl-verify=ignore -S smtp-use-starttls -S smtp-auth=login -S smtp="$SMTP" -S from="$FROM_MAIL" -S smtp-auth-user="$LOGIN" -S smtp-auth-password="$LOGIN_PASSWORD" $TO_MAIL

#Truncate logs
echo -n > $ACCESS_LOG
echo -n > $ERROR_LOG
Now I can just throw this script at cron and just check my email. I have another GMail account that is used to sends the messages, don't have to bother with the Sent mail and this clear text pword. I just put a filter that applies a label to the particular email in GMail. Makes storing logs pretty easy.

I'd rather not have to ignore the ssl failures but I'll save that for another day.

Thank you thoron for starting this and rworkman for pointing me to mailx.

Last edited by pricejm; 10-06-2007 at 03:37 PM.
 
  


Reply

Tags
certificate, cron, email, failed, gmail, local, log, mailx, smtp, verify


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Sending logs by email from D Link router taylorkh Linux - Hardware 1 08-27-2007 08:03 PM
help with email logs - please dwmartini Linux - Server 3 07-16-2007 09:08 AM
Automatic email sent when ftp user logs in joadoor Linux - Security 2 04-14-2006 12:20 AM
Send logs to email address bond00 Linux - Networking 1 03-28-2006 07:01 PM
how to send logs (etc.) to email address??? win32sux Slackware 7 08-26-2004 01:48 PM


All times are GMT -5. The time now is 09:34 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration