在带有所有参数的脚本上运行 nohup 命令

发布于 2024-12-16 10:31:28 字数 632 浏览 5 评论 0原文

我正在尝试使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

牵你的手,一向走下去 2024-12-23 10:31:28

只需将“build_all”的参数放在命令行上,就像任何其他命令一样:

nohup time ./build_all args to build_all go here &

参数将传递给“build_all”,而不是“time”或“nohup”。 shell 将正确解释 & 符号,并且不会将其作为参数传递给任何命令。

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.

厌倦 2024-12-23 10:31:28

脚本参数(参数)只需跟在脚本名称后面并在 & 符号前面。

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文