From owner-freebsd-questions Mon Mar 17 13:55:45 2003 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 229C637B401 for ; Mon, 17 Mar 2003 13:55:44 -0800 (PST) Received: from mired.org (ip68-97-54-220.ok.ok.cox.net [68.97.54.220]) by mx1.FreeBSD.org (Postfix) with SMTP id 05B6143F3F for ; Mon, 17 Mar 2003 13:55:43 -0800 (PST) (envelope-from mwm-dated-1048370141.70a18d@mired.org) Received: (qmail 66721 invoked from network); 17 Mar 2003 21:55:41 -0000 Received: from localhost.mired.org (HELO guru.mired.org) (127.0.0.1) by localhost.mired.org with SMTP; 17 Mar 2003 21:55:41 -0000 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-ID: <15990.17500.959418.820951@guru.mired.org> Date: Mon, 17 Mar 2003 15:55:40 -0600 To: "Chris Phillips" Cc: Subject: Re: Pushing commands to the background In-Reply-To: <004001c2ecc9$6cd20500$1508060a@furrie.net> References: <004001c2ecc9$6cd20500$1508060a@furrie.net> X-Mailer: VM 7.07 under 21.1 (patch 14) "Cuyahoga Valley" XEmacs Lucid X-face: "5Mnwy%?j>IIV\)A=):rjWL~NB2aH[}Yq8Z=u~vJ`"(,&SiLvbbz2W`; h9L,Yg`+vb1>RG% *h+%X^n0EZd>TM8_IB;a8F?(Fb"lw'IgCoyM.[Lg#r\ From: Mike Meyer X-Delivery-Agent: TMDA/0.71 (Hoop, Jr.) Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG In <004001c2ecc9$6cd20500$1508060a@furrie.net>, Chris Phillips typed: > > hostname > uptime > ping -c 100 ftp.furrie.net > traceroute ftp.furrie.net > > I'd like to push all the commands into the background & be able to log > off and let it do its business unattended. Unfortunately, with my > lacking knowledge, so far I have managed this, (sad isn't it)... > > (ping -c 10 ftp.furrie.net > /tmp/results && cat /tmp/results | mail > chris@furrie.net &) > > Even with an & at the end of this command, I do not get my prompt back > :-( The easiest oneliner is: (hostname; uptime; ping -c 100 ftp.furrie.net; traceroute ftp.furrie.net) | mail chris@furrie.net & The reason your one-liner didn't come back fromm the background is that you didn't background the shell running the command, but backgrounded the commands the shell was waiting on. Putting a bunch of commands in parens separated by ; runs them one after the other in a subshell, with output going to standard output. Just send that output to mail and you're done. http://www.mired.org/consulting.html Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information. To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message