【问题标题】:Run shell script with arguments using nohup使用 nohup 运行带参数的 shell 脚本
【发布时间】:2013-08-10 06:21:18
【问题描述】:

我需要远程登录到服务器并使用nohup 在后台运行带有参数的shell 脚本。但我收到一个错误。我在语法上遗漏了什么吗?

我的代码:

ssh -t -t user@servername nohup /path/myscript.sh argument1 argument2 & > /path/myscrip_logfile.log

输出:

Invalid null command.

【问题讨论】:

标签: shell arguments nohup


【解决方案1】:

nohup 接受您提供的参数,“& >”应该是“&>”,并且整个命令应该放在引号中,否则我认为您正在重定向 ssh 命令的标准输出,所以试试这个:

ssh -t -t user@servername "nohup /path/myscript.sh argument1 argument2 &> /path/myscrip_logfile.log"

【讨论】:

  • 我按照建议更改了它,但仍然出现相同的错误。我们需要在日志文件名的末尾加上“&”吗?
  • 应该不需要,但你可以试试。您确定您正在运行的脚本不会产生该错误吗?
猜你喜欢
  • 2022-10-20
  • 2011-10-09
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-01-12
  • 2016-12-18
相关资源
最近更新 更多