[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [SAGE] Output from "cron" command



mailx(1) on Solaris 2.6 always seems to interpret tilde options, even 
if stdin is not a tty, which is not what the man page says it is 
supposed to do.  I can't easily get to machines running  a more recent 
version of Solaris right now, so I would be curious if Solaris 8/9 act 
the same way.

Does anyone have any good suggestions on replacements for mailx on 
Solaris?  /usr/bin/mail doesn't let you set the subject on the 
command-line, but it will look for headers when you pass it a message 
on stdin.  /usr/ucb/Mail seems to have the same problem as mailx.  I 
tossed together a little perl script that I called "ourmail" and have 
attached that uses /usr/bin/mail and I think would work okay, but I 
haven't tested it out that much.

ourmail



Also, Tom Reingold wrote:                                               
               ,
 > How about sending the mail to /dev/null and using some tool, such as
 > "mon" to monitor your services.

I cringe when people send mail to /dev/null, because they always end up 
getting bitten by it.  I've seen so many broken things stay that way 
for days or weeks until users start reporting a problem because no one 
was watching an automated report or the output from a batch process was 
getting thrown away to /dev/null.

I've found that making liberal use of "egrep -v" to filter out known 
good output from cron jobs is a great and simple way to keep 
administrators from getting junk mail from cron when things are okay, 
while at the same time making sure that they get notified when 
something is abnormal.  I'm also a fan of forwarding all mail from 
automated processes to a single account that gets filtered by procmail. 
  Procmail logs everything that should be logged, can call scripts to 
store data in a RRD (http://www.rrdtool.org) for data collection and 
reporting, and can forward "bad" things off to humans to deal with, 
ideally by creating a ticket in your problem tracking system.

Service monitoring is also a must-have so that you can know when 
something breaks before the users are beating down your door. :)  Being 
able to say "oh, yeah, I fixed that problem last night" or "I've been 
working on it for 10 minutes, it should be fixed soon" is much better 
than "Email problem?  What email problem?"


	Have a good one,
	- djg

On Friday, April 25, 2003, at 01:55 PM, John Sellens wrote:

> | From: merlyn@stonehenge.com (Randal L. Schwartz)
> |
> | John>     14 3 * * * /usr/local/sbin/DAILY_stuff 2>&1 | \
> | John> 	/usr/local/bin/ifinput /usr/bin/mailx \
> | John> 	-s "`/bin/uname -n` DAILY_stuff output" jsellens
> |
> | And now if somehow I can get DAILY_stuff to spit out a line
> | that starts with a tilde, you've just b33n 0wn3d.
> |
> | Don't use mailx.  Or at least not until it can be told "don't
> | interpret lines that start with tilde specially".
>
> I haven't tested this (recently?), but the Solaris 2.5.1 man page
> for mailx(1) describes the -~ option
>      -~              Interpret tilde escapes in the input even if
> 		     not reading from a tty.
> which implies that a ~ in a pipe would not have any unfortunate
> effects.  The FreeBSD mail(1) command needs -I to interpret tildes
> when input is not a terminal.
>
> I think the old Berkeley mail command may have had this problem,
> but it seems to have been fixed in many (most?) places by now.
> (I think we fixed it at UWaterloo 1987/08/28 if the RCS log can
> be believed.)
>
> But you're right - it's almost always a bad idea to use a
> program made for interactive use in a non-interactive way,
> because of just these possibilities.
>
> I just fell into bad habits because I knew I could trust
> my environment. :-)
>
> Cheers!
>
> John
>