running nohup command on script that takes all parameters

Flethuseo picture Flethuseo · Nov 16, 2011 · Viewed 19.4k times · Source

I am trying to run a script with nohup, but the command happens to take an entire line of parameters with the variable $*. I try running the command like this:

    nohup time ./build_all all &

But this is giving me the following error in nohup.out:

./build_all: DISPLAY=ted:0.0: is not an identifier

Any help appreciated.

Ted

==================================================================================

I realize that Peter John Acklam was right. The error is not because of nohup, but because of the script, I am not sure what I am doing wrong because the syntax seems correct to me. It is also kind of strange that when I run the script on its own, I don't see the error, but when I try to run with nohup, I see the strange error.

Anyhow, the beginning of the script looks like this:

#!/bin/bash

export DISPLAY=ted:0.0 # sets the display
export RELEASE=v1.0

node=`uname -n`

Answer

Peter John Acklam picture Peter John Acklam · Nov 16, 2011

Simply place the arguments to “build_all” on the command line, as for any other command:

nohup time ./build_all args to build_all go here &

and the arguments will be passed to “build_all”, not to “time” or “nohup”. The ampersand will be interpreted correctly by the shell, and will not be passed as an argument to any of the commands.