[Novalug] bash scripting

Ben Creitz creitz at gmail.com
Fri Jun 1 22:56:08 EDT 2007


On 6/1/07, Miguel Gonzalez Castaños <miguel_3_gonzalez at yahoo.es> wrote:
> Hi,
>
>  I want to launch a command using nohup in a bash script, and when the
> command has finished send an email with the log file. I prefer not to
> have to type nohup script.sh & and be able to wait inside my script.sh :
>
>   nohup command > log &
>
>   mail -s "subject" email at address < log

If, as you say, you want to "wait" for the command to finish, then it
sounds like you don't want it to run in the background.  So maybe you
want something like this:

nohup cmd > log
mail -s "blah" email at where < log

But when you take this approach, only cmd is safe from "hangups."  The
mail command is not.  So maybe as an earlier poster said, you should
just trap the signals... you can find that with a google search.

Or maybe we should know why you need nohup or signal trapping in the
first place?

Ben



More information about the Novalug mailing list