From owner-freebsd-questions@FreeBSD.ORG Fri Oct 10 13:42:04 2003 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 0BD5516A4B3 for ; Fri, 10 Oct 2003 13:42:04 -0700 (PDT) Received: from dan.emsphone.com (dan.emsphone.com [199.67.51.101]) by mx1.FreeBSD.org (Postfix) with ESMTP id 525E443FA3 for ; Fri, 10 Oct 2003 13:42:03 -0700 (PDT) (envelope-from dan@dan.emsphone.com) Received: (from dan@localhost) by dan.emsphone.com (8.12.9/8.12.9) id h9AKg2oW022012 for freebsd-questions@freebsd.org; Fri, 10 Oct 2003 15:42:02 -0500 (CDT) (envelope-from dan) Date: Fri, 10 Oct 2003 15:42:02 -0500 From: Dan Nelson To: freebsd-questions@freebsd.org Message-ID: <20031010204202.GF77306@dan.emsphone.com> References: <20031010202755.GA74202@beast.clarksys.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20031010202755.GA74202@beast.clarksys.com> X-OS: FreeBSD 5.1-CURRENT X-message-flag: Outlook Error User-Agent: Mutt/1.5.4i Subject: Re: Redirect to /dev/null X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 10 Oct 2003 20:42:04 -0000 In the last episode (Oct 10), Max Clark said: > What is the proper way to redirect output to /dev/null? I've been > using the following in my crontab but output is still ending up in my > mailbox. > > ... 2>&1 > /dev/null I'm sure this is in a sh FAQ someplace: What you did was dup fd1 onto fd2, then redirect fd1 to /dev/null: fd1 -> stdout fd2 -> stderr 2>&1 fd1 -> stdout fd2 -> stdout >/dev/null fd1 -> /dev/null fd2 -> stdout Swap the two redirects, so you redirect fd1 to /dev/null, then dup it onto fd2: fd1 -> stdout fd2 -> stderr >/dev/null fd1 -> /dev/null fd2 -> stdout 2>&1 fd1 -> /dev/null fd2 -> /dev/null -- Dan Nelson dnelson@allantgroup.com