LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 11-02-2006, 06:19 PM   #1
hattori.hanzo
Member
 
Registered: Aug 2006
Posts: 168

Rep: Reputation: 15
logrotate -m & postfix possible?


I currently have logrotate rotating my logs once a day via a cron job. I would like to set it up to email me as well. I installed postfix.

I have tested to send mail from the command line with this line and it works fine:

Code:
echo -e "subject: Test Email\nJust testing\n." | sendmail -t john@email.com
From the logrotate man, the default mail command is /bin/mail -s. I checked my system and there is no such command, so I am using the -m switch to substitute my own mail command. I have modified my cron job to the following but am still having problems with mail

Code:
/opt/sbin/logrotate -m 'sendmail -t john@email.com' /opt/etc/logrotate.conf
Code:
/opt/sbin/logrotate -m 'echo -e "subject: Test Email\nJust testing\n." | sendmail -t john@email.com' /opt/etc/logrotate.conf
Thanks.
 
Old 11-02-2006, 10:13 PM   #2
trickykid
LQ Guru
 
Registered: Jan 2001
Posts: 24,149

Rep: Reputation: 269Reputation: 269Reputation: 269
Logrotate is usualling invoked by cron. Why don't you just add the MAILTO option in your crontab? In some or all cases, it's called from within one of the cron.* directories in /etc, like /etc/cron.daily

The mail command is usually provided by the mailx or nail package, just depends on what distribution your using.

And why would you want to have an email each and everytime logrotate runs? As far as I know and by default, it's not going to give you any output from it.
 
Old 11-02-2006, 10:47 PM   #3
hattori.hanzo
Member
 
Registered: Aug 2006
Posts: 168

Original Poster
Rep: Reputation: 15
I don't need a notification of when the cron job is run, but I wanted to set it up so that the logs (ie. failed logins etc.. auth.log etc..) are emailed to me every night.

This seems to be a feature (-m --mail option) in the logrotate script.

"-m, --mail <command>
Tells logrotate which command to use when mailing logs. This command should accept two arguments: 1) the subject of the message, and 2) the recipient. The command must then read a message on standard input and mail it to the recipient. The default mail command is /bin/mail -s."

I am curious, how do folks usually email logs to themselves, if they need to monitor a specific log?

Thanks for your reply.

Last edited by hattori.hanzo; 11-02-2006 at 10:50 PM.
 
  


Reply



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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
local_recipient_maps & postfix & text file paul_mat Linux - Networking 1 01-11-2006 07:38 AM
cron.daily & logrotate cccc SUSE / openSUSE 1 07-08-2005 12:06 PM
logrotate && cron pH* Linux - General 9 12-21-2004 10:38 AM
Fedora & Postfix & SpamAssassin bigdogg Linux - Software 20 09-16-2004 03:08 PM
Postfix & MySQL & POP3 on Redhat.. hct224 Linux - Newbie 0 05-20-2004 03:15 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 06:57 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
Open Source Consulting | Domain Registration