LinuxQuestions.org
Visit the LQ Articles and Editorials section
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 04-11-2002, 07:16 PM   #1
Stingreen
Member
 
Registered: May 2001
Location: Baltimore,MD,USA,Earth,Some Galaxy, We haven't gone that far!
Distribution: Redhat 7.3
Posts: 103

Rep: Reputation: 15
Automatic email sending with sendmail?


I want sendmail to send me the weekly logs every sunday at 1 o' clock. Is there any way to do this?
Well, if there is a command for this, I can setup the cronjobs to schedule weekly, but the problem is I don't know if there is a command for this or not..
Thank you,
 
Old 04-11-2002, 07:38 PM   #2
jpweston
Member
 
Registered: Mar 2002
Location: Sacramento, CA
Distribution: Slackware 8.1; Debian 3.0
Posts: 222

Rep: Reputation: 30
You can setup a cronjob to execute the following command:

sendmail email@address.com < filename

That will cat the file into an email which will end up in the designated email box. There are a bunch of flags you can use too in order to specify a subject or get verbose output to capture in a log file separate from cron messages.

You can test it out from the command line first and tweak it as you need.

Hope that helps.

j.
 
Old 04-12-2002, 04:39 PM   #3
Stingreen
Member
 
Registered: May 2001
Location: Baltimore,MD,USA,Earth,Some Galaxy, We haven't gone that far!
Distribution: Redhat 7.3
Posts: 103

Original Poster
Rep: Reputation: 15
Thanks..
Can I expand my question a little bit?
Well, now, there is a script called "stats"
What I wanna do is, I want crontab to execute the stats like this,
# stats /var/log/maillog
and have the output mailed to myself.
Can I do this also?
thank you much.
 
Old 04-15-2002, 12:50 PM   #4
jpweston
Member
 
Registered: Mar 2002
Location: Sacramento, CA
Distribution: Slackware 8.1; Debian 3.0
Posts: 222

Rep: Reputation: 30
Not knowing exactly how your stats script works, I'll take a stab....

If the stats script is generating a file (i.e. /var/log/maillog), then you can do a couple of things (off the top of my head):

1. Make the last step of the stats script be to execute the sendmail command with the < filename option.

2. Set up a cron job for a separate script that will check for the file and timestamp. If the conditions are met, then send the mail.

j.
 
Old 04-15-2002, 01:54 PM   #5
Stingreen
Member
 
Registered: May 2001
Location: Baltimore,MD,USA,Earth,Some Galaxy, We haven't gone that far!
Distribution: Redhat 7.3
Posts: 103

Original Poster
Rep: Reputation: 15
Unfortunately it doesn't create a log file, that's what I'm concerned about.
The script is called sendmail Log analyzer, it's been written in PERL and a great way to check your sendmail logs..
You can click here for more information.
Well, the problem is, I have to execute it everytime I want to check the stats. Because It works if only executed at that time, it doesn't log anything..
Do I still have a chance,
Thank you much

Last edited by Stingreen; 04-15-2002 at 01:57 PM.
 
Old 04-15-2002, 02:04 PM   #6
jatimon
Member
 
Registered: Apr 2002
Posts: 33

Rep: Reputation: 15
stdout

does the script write to standard out.

if it does, then your work is done. Just run it from root's cron and the output will be automaticall mailed to root.

if you don't want it mailed to root, I believe that you can set the person to email stdout/stderr to with an evironment var.

or something like this

mail you@whatever.com < `stats /var/log/maillog`
 
Old 04-15-2002, 02:35 PM   #7
Stingreen
Member
 
Registered: May 2001
Location: Baltimore,MD,USA,Earth,Some Galaxy, We haven't gone that far!
Distribution: Redhat 7.3
Posts: 103

Original Poster
Rep: Reputation: 15
Quote:
mail you@whatever.com < `stats /var/log/maillog`
This command doesn't work and gives me the following,

bash: `sendmail_stats /var/log/maillog`: ambiguous redirect

Quote:
if it does, then your work is done. Just run it from root's cron and the output will be automaticall mailed to root.
Do you mean that every cronjob executed for the particular user is mailed to the user automaticly??
 
Old 04-15-2002, 02:40 PM   #8
jatimon
Member
 
Registered: Apr 2002
Posts: 33

Rep: Reputation: 15
Do you mean that every cronjob executed for the particular user is mailed to the user automaticly??

yes.

everything that goes to stdout and stderr will be mailed to the owner of the crontab.

I will look into the other issue of the ambiguous redirect
 
Old 04-15-2002, 02:43 PM   #9
jatimon
Member
 
Registered: Apr 2002
Posts: 33

Rep: Reputation: 15
try this

stats /var/log/maillog | mail you@whatever.com
 
Old 04-15-2002, 02:50 PM   #10
Stingreen
Member
 
Registered: May 2001
Location: Baltimore,MD,USA,Earth,Some Galaxy, We haven't gone that far!
Distribution: Redhat 7.3
Posts: 103

Original Poster
Rep: Reputation: 15
Oh mann!!
Thank you, thank you, thank you..!!!



Danny
 
Old 04-15-2002, 02:55 PM   #11
jatimon
Member
 
Registered: Apr 2002
Posts: 33

Rep: Reputation: 15
No Prob
 
  


Reply


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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Creating A Second Email Address For Email Account On Sendmail treedstang Linux - Software 1 04-27-2004 10:31 PM
Sending Email to an SMTP address from sendmail guilmetrp Linux - Newbie 6 03-01-2004 08:51 PM
Sending email to a smtp address through sendmail guilmetrp Linux - General 0 02-27-2004 08:02 PM
sending an email to a email address after a perl operation meluser Programming 9 04-07-2003 01:26 PM
Automatic Email lesath Linux - General 3 04-30-2001 05:24 PM


All times are GMT -5. The time now is 01:43 PM.

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