在带有所有参数的脚本上运行 nohup 命令
我正在尝试使用 nohup 运行脚本,但该命令恰好需要一个 带有变量 $* 的整行参数。我尝试运行这样的命令:
nohup time ./build_all all &
但这在 nohup.out 中给了我以下错误:
./build_all: DISPLAY=ted:0.0: is not an identifier
任何帮助表示赞赏。
特德
=================================================== ===================================
我意识到彼得·约翰·阿克拉姆是对的。该错误不是因为 nohup,而是因为脚本,我不确定我做错了什么,因为语法对我来说似乎是正确的。还有一点奇怪的是,当我单独运行脚本时,我没有看到错误,但是当我尝试使用 nohup 运行时,我看到了奇怪的错误。
不管怎样,脚本的开头是这样的:
#!/bin/bash
export DISPLAY=ted:0.0 # sets the display
export RELEASE=v1.0
node=`uname -n`
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`
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
只需将“build_all”的参数放在命令行上,就像任何其他命令一样:
参数将传递给“build_all”,而不是“time”或“nohup”。 shell 将正确解释 & 符号,并且不会将其作为参数传递给任何命令。
Simply place the arguments to “build_all” on the command line, as for any other command:
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.
脚本参数(参数)只需跟在脚本名称后面并在 & 符号前面。
The script arguments (parameters) simply follow the script's name and preceed the ampersand.