LinuxQuestions.org
Help answer threads with 0 replies.
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 01-06-2015, 10:17 AM   #1
marciano
Member
 
Registered: Oct 2005
Location: Uruguay
Distribution: CentOS 6.6 Ubuntu 12.4 MacOS 10.9
Posts: 121

Rep: Reputation: 17
Cron and maillog


In Centos 5 rotated files were named as maillog.1 maillog.2, etc
Now in Centos 6 I see they are named as maillog-20150104, adding the date they were created
I have a cron job that sends me a weekly report of mail server.

Code:
perl /usr/local/pflogsumm/pflogsumm.pl /var/log/maillog.1 2>&1 |/bin/mailx -s "Last week email report" root
which, obviously sends an error: maillog.1 does not exist.

How can I change that code to analyze the last rotated mail log file?
Thank you

Last edited by marciano; 01-06-2015 at 10:21 AM.
 
Old 01-06-2015, 12:40 PM   #2
marciano
Member
 
Registered: Oct 2005
Location: Uruguay
Distribution: CentOS 6.6 Ubuntu 12.4 MacOS 10.9
Posts: 121

Original Poster
Rep: Reputation: 17
I created an executable file under /etc/cron.weekly (Sunday is the day when maillog rotates)

#!/bin/bash
DATE='maillog-'$(date +"%Y%m%d" -d "last Sunday")

perl /usr/local/pflogsumm/pflogsumm.pl /var/log/$DATE 2>&1 |/bin/mailx -s "......" root
 
  


Reply

Tags
crontabs, maillog



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
Strange Cron directories: /var/spool/cron/cron.GfqqGO Woodsman Slackware 4 05-11-2011 02:37 PM
cron.hourly cron.weekly cron.monthly and 0anacron. Are they necessary? glore2002 Debian 2 09-30-2009 08:57 PM
adding a perl script to cron.daily / cron.d to setup a cron job CrontabNewBIE Linux - Software 6 01-14-2008 08:16 AM
why is maillog on my server getting created in /var/log/maillog.3 ? weblink_dipti Linux - Software 2 06-16-2007 04:47 AM
cron not working from crontab nor form /etc/cron/cron.d. What did SuSE change? JZL240I-U SUSE / openSUSE 11 01-04-2007 01:57 AM

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

All times are GMT -5. The time now is 05:22 PM.

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