delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2008/07/21/13:31:58

X-Recipient: archive-cygwin AT delorie DOT com
X-Spam-Check-By: sourceware.org
Message-ID: <4884C7F3.3C7A47C4@dessent.net>
Date: Mon, 21 Jul 2008 10:31:31 -0700
From: Brian Dessent <brian AT dessent DOT net>
X-Mailer: Mozilla 4.79 [en] (Windows NT 5.0; U)
MIME-Version: 1.0
To: Julio Emanuel <costaju AT gmail DOT com>
CC: Cygwin Mailing list <cygwin AT cygwin DOT com>
Subject: Re: cron and mail: a stupid question (please don't kill me)
References: <af075b00807210917s424b5400u414fc4c422d28843 AT mail DOT gmail DOT com> <af075b00807211011n5f1d0ce2q14f437d73c9df407 AT mail DOT gmail DOT com>
X-IsSubscribed: yes
Reply-To: cygwin AT cygwin DOT com
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com

Julio Emanuel wrote:

> I've searched a bit already, and have been through the cron, ssmtp,
> and crontab manpages. Still, there is something that I don't quite
> understand: why on earth the cron job's output are put in e-mails??

cron was written with the intention of being able to run jobs for normal
users, not just sysadmins.  How else is it supposed to notify a user
that a job it ran on that users behalf completed with errors?  Users
might not have access to the system logs and even if they did they
almost certainly wouldn't know or think to check them.  But on a
traditional unix system every user does have a local mail spool file and
users are accustomed to reading email, so it's a pretty natural fit.

But cron itself really doesn't know anything about email per se, it just
knows that when the job outputs to stderr, it pipes that output to a
"/usr/sbin/sendmail", whatever that is.  That is typically a symlink to
something that sends mail but it doesn't have to be.

> All I want to do is:
> a) have some jobs running unnatended and scheduled; (apparently done,
> whith some simple tests)
> b) have the output of this jobs LOGGED, preferably on syslog, with
> some identification of the process who generated it; (don't have a
> clue??!)

Did you read /usr/share/doc/Cygwin/cron-*.README?  It explains cronlog
which if symlinked as sendmail will log the output.

Alternatively, you can do whatever you want with your job's output by
redirecting or piping stdout and/or stderr to a location or program of
your choice directly in the crontab entry.  There's nothing that says
you need to let cron handle it.  You can use 'logger' if you want that
location to be the syslog.

Brian

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019