From owner-freebsd-questions@FreeBSD.ORG Tue Oct 27 18:45:49 2009 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id A82851065676 for ; Tue, 27 Oct 2009 18:45:49 +0000 (UTC) (envelope-from kellymartin@gmail.com) Received: from mail-qy0-f176.google.com (mail-qy0-f176.google.com [209.85.221.176]) by mx1.freebsd.org (Postfix) with ESMTP id 6079E8FC08 for ; Tue, 27 Oct 2009 18:45:48 +0000 (UTC) Received: by qyk6 with SMTP id 6so11365qyk.3 for ; Tue, 27 Oct 2009 11:45:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:message-id:subject:from:to:cc:content-type; bh=0aYH2nFfhv4LZfJQUL+bindWUCh4IxUZw4AZ4RQhpCw=; b=KuH85vDb17Pi9q/jntbMJ7sq9dxhq8ZJsEFN2O6o5r/QQMUEopRVUvgDu/ErI0V19r yKFhJFk3cmrUw/bC0Hm6FgthWV1YHwz/rHERgbxwVAQkfFKSF2BeVoRkT0yoIALOlvMb cJukoWFOUHXa1tK560lKeiX8pVPB8YXZpF1M4= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; b=d9HwVCAf9id/zKKK7Fk/nFbQhCZrTMeQdYof3Ap/rrzp5oKWnXofLvvCn1SJt1KuTM Gelv/btqEd6LS0OXgiDze98GH65BS4T6QQK8GdBMA1cqre8HfftXgnEAltYX3C1tfJsN qNcQwCk/50hUYTfykaAmH2e5Dtq5govmkhd4I= MIME-Version: 1.0 Received: by 10.224.44.2 with SMTP id y2mr8630109qae.125.1256669148501; Tue, 27 Oct 2009 11:45:48 -0700 (PDT) In-Reply-To: References: <1338880b0910240008h5d5e7846q8ccf184728d9e036@mail.gmail.com> <20091025021009.051de285.dcdowse@gmx.net> Date: Tue, 27 Oct 2009 12:45:48 -0600 Message-ID: <1338880b0910271145m73dbb11bjada79a76ccea35e2@mail.gmail.com> From: Kelly Martin To: krad Content-Type: text/plain; charset=ISO-8859-1 Cc: FreeBSD Questions , "Daniel C. Dowse" Subject: Re: changing cron's From: address in emails X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 27 Oct 2009 18:45:49 -0000 On Sun, Oct 25, 2009 at 11:19 AM, krad wrote: > > >> On Sat, 24 Oct 2009 01:08:21 -0600 >> Kelly Martin wrote: >> >> > Greetings, here's a simple question for the FreeBSD gurus out there. I >> > have several servers running cron scripts daily for me, and they all >> > send me e-mail with their output. Regardless of which server it is, >> > each of these e-mails have the From: address looking exactly the same. >> > They all say they are from the "Cron Daemon". Fine, but I'd like to >> > know more clearly which server the cron output is from. >> > >> > How can I change the From: address of these emails to "Myserver Cron >> > Daemon" instead? I know cron runs as the user, so it's not immediately >> > obvious to me how to change the From: field. Already the subject line >> > says something like "Cron ..." but this doesn't stand >> > out enough for my tired eyes. > > The simplist way to do it is get you scripts to print out a to, from and > subject line at the top of their output containing the information you want. > eg > > To: your@mailbox.com > From: scriptname@hostname.com > Subject: scriptname, hostname > > other script output > > > Then in the cron pipe the output into sendmail with the t flag > > eg > > 1 1 * * * somescript 2>&1 | /usr/sbin/sendmail -t > > you will then get the loverly named emails That is very cool, thank-you! It works beautifully. And as a bonus I've learned something new about how to e-mail the output from my scripts, which can be useful for all sorts of things. Kelly