Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

running nohup command on script that takes all parameters

Tags:

bash

nohup

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`
like image 304
Flethuseo Avatar asked Nov 16 '11 14:11

Flethuseo


2 Answers

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.

like image 74
Peter John Acklam Avatar answered Nov 30 '22 04:11

Peter John Acklam


The script arguments (parameters) simply follow the script's name and preceed the ampersand.

like image 33
JRFerguson Avatar answered Nov 30 '22 06:11

JRFerguson