Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 17 Mar 2003 15:55:40 -0600
From:      Mike Meyer <mwm-dated-1048370141.70a18d@mired.org>
To:        "Chris Phillips" <Chris@furrie.net>
Cc:        <FreeBSD-Questions@FreeBSD.Org>
Subject:   Re: Pushing commands to the background
Message-ID:  <15990.17500.959418.820951@guru.mired.org>
In-Reply-To: <004001c2ecc9$6cd20500$1508060a@furrie.net>
References:  <004001c2ecc9$6cd20500$1508060a@furrie.net>

next in thread | previous in thread | raw e-mail | index | archive | help
In <004001c2ecc9$6cd20500$1508060a@furrie.net>, Chris Phillips <Chris@furrie.net> 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.

	<mike
-- 
Mike Meyer <mwm@mired.org>		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




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?15990.17500.959418.820951>