LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices

Reply
 
Search this Thread
Old 01-01-2008, 12:21 AM   #1
praveenkumarj
LQ Newbie
 
Registered: Jan 2008
Posts: 3

Rep: Reputation: 0
Smile How to get log files and mail them ???


Hi friends, I am new to this forum.
Am struck in problem now.
If anyone helps me regarding this, it will be great help for me.

The problem is I have to fetch log files from a specified location and mail it to the given email-id.
Can anyone help me to solve this problem...?

waiting for the results.....

Regards,
Praveen
 
Old 01-01-2008, 03:40 AM   #2
meetscott
Samhain Slackbuild Maintainer
 
Registered: Sep 2004
Location: Phoenix, AZ, USA
Distribution: Slackware
Posts: 411

Rep: Reputation: 42
I would assume you want secure communications for your log files so just use scp. Something like "scp remote_host_name:/directory/sub_directory/log_file ." <- that's a period or dot, meaning the current directory for the log file destination. Before this would work, you'd need to set up secure shell private keys so you won't have to put in passwords in your scripts. You can edit crontab to send this out periodically under the proper user id.

Next you need to set up an MTA like sendmail. That's complex, but then you can e-mail from scripts using something like:
cat log_file | mail -s "Here is the email subject" email-id@some-domain.com &

the & is used to run in the background. This will put the log file contents in the body of the email. You don't have to pipe to the mailer file into the mailer. This is just one way to do it. I use it for daily reporting on my servers. It works well. The hardest part was setting up sendmail.

Unfortunately no one can set your system up to do this stuff or give you the specific steps. We can help you with specific challenges for your circumstances or set up, but without comprehensive information, no one can solve your problem outright. So I did the best I could by giving you one general method that works for me.
 
Old 01-02-2008, 01:24 AM   #3
SonJelfn
Member
 
Registered: Aug 2003
Location: Sendai, Japan
Distribution: Slackware, Slackware64, Debian
Posts: 63

Rep: Reputation: 16
Logwatch (http://www2.logwatch.org:81/) is a very handy tool that can probably do what you want with a little less configuration.

Logwatch is a customizable log analysis system which might take you an afternoon or so to understand, but you can make it do whatever you want and then send the report by mail.

The flexibility means you could send the entire log file (if your mail server accepts the size of the log file) or just a summary of what went on during the day.

Usually it configures itself under cron, which is mighty helpful.

Most distributions have Logwatch as a package along with summary tools for all the main services (mail, NFS, ssh, bind etc).

Hope the info helps.

Good luck!
 
Old 01-02-2008, 09:52 AM   #4
meetscott
Samhain Slackbuild Maintainer
 
Registered: Sep 2004
Location: Phoenix, AZ, USA
Distribution: Slackware
Posts: 411

Rep: Reputation: 42
I've heard of Logwatch. Thanks for posting that reply. I've always written my own filters, summaries, and reports. I should take a look at that for myself.
 
Old 01-02-2008, 10:10 AM   #5
praveenkumarj
LQ Newbie
 
Registered: Jan 2008
Posts: 3

Original Poster
Rep: Reputation: 0
Smile How to get log files and mail them ???

Hi MeetScott.
Thanks for your suggestion.

I tried the following command directly without using scp,

cat file.txt|mail -s "mailing" praveen198537@gmail.com

But I didn't get any mail to praveen198537@gmail.com
I think the above command alone sufficient... right?

Please reply soon as possible.
I'm doing internal project and I have to complete it soon.

Can you send me your personal email id for further clarifications.
Bye MeetScott.


Quote:
Originally Posted by meetscott View Post
I would assume you want secure communications for your log files so just use scp. Something like "scp remote_host_name:/directory/sub_directory/log_file ." <- that's a period or dot, meaning the current directory for the log file destination. Before this would work, you'd need to set up secure shell private keys so you won't have to put in passwords in your scripts. You can edit crontab to send this out periodically under the proper user id.

Next you need to set up an MTA like sendmail. That's complex, but then you can e-mail from scripts using something like:
cat log_file | mail -s "Here is the email subject" email-id@some-domain.com &

the & is used to run in the background. This will put the log file contents in the body of the email. You don't have to pipe to the mailer file into the mailer. This is just one way to do it. I use it for daily reporting on my servers. It works well. The hardest part was setting up sendmail.

Unfortunately no one can set your system up to do this stuff or give you the specific steps. We can help you with specific challenges for your circumstances or set up, but without comprehensive information, no one can solve your problem outright. So I did the best I could by giving you one general method that works for me.
 
Old 01-02-2008, 10:17 AM   #6
praveenkumarj
LQ Newbie
 
Registered: Jan 2008
Posts: 3

Original Poster
Rep: Reputation: 0
Smile How to get log files and mail them ???

Thanks Jelfn...
Have a nice day.

Quote:
Originally Posted by SonJelfn View Post
Logwatch (http://www2.logwatch.org:81/) is a very handy tool that can probably do what you want with a little less configuration.

Logwatch is a customizable log analysis system which might take you an afternoon or so to understand, but you can make it do whatever you want and then send the report by mail.

The flexibility means you could send the entire log file (if your mail server accepts the size of the log file) or just a summary of what went on during the day.

Usually it configures itself under cron, which is mighty helpful.

Most distributions have Logwatch as a package along with summary tools for all the main services (mail, NFS, ssh, bind etc).

Hope the info helps.

Good luck!
 
  


Reply

Tags
files, get, how, log, mail


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
Emailing log files and system mail... AnRkey Linux - Security 6 11-10-2005 06:17 PM
Sending system log files to an e-mail account darkbluex Linux - Security 1 10-27-2004 07:37 AM
parsing mail.log with perl and calculate mail traffic on domain base markus1982 Programming 1 03-18-2003 06:22 AM
Can log files be time stamped? (such as FTP login and transfer log files) bripage Linux - Networking 6 08-08-2002 10:55 PM
How to remove files in /var/log /news and /mail keirobyn Linux - Newbie 6 07-19-2002 04:26 AM


All times are GMT -5. The time now is 07:53 AM.

Main Menu
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