[Novalug] bash scripting
Ben Creitz
creitz at gmail.com
Sat Jun 2 14:24:26 EDT 2007
On 6/2/07, donjr <djr1952 at hotpop.com> wrote:
> The answer to your request for a simple shell script that runs a command
> in the backgrounds and allows you to close the terminal where it was
> started from is as follows:
>
> #!/bin/sh
> trap "" 1 # Trap Hangup (usually logout) {ie what nohup does <GRIN>}
>
> # Now run the command in the "background" while redirecting the
> # wrapping background shell's standard out and error to /dev/null
> ( ( mycommand | mail -s "done" me at mine.com )& ) >/dev/null 2>&1
>
> exit 0 # end of the script.
>
> And yes all the command grouping '()' is required in order for it to
> work correctly.
Ahhh, I guess I was thinking that a script whichs spawns a background
process may not finish until its background process finishes. I was
wrong!
Ben
More information about the Novalug
mailing list