在通过nohup

时间:2016-12-22 19:30:07

标签: bash nohup

我有一个脚本,当我运行到屏幕时,它运行得很好。 目录结构如下:

/home/username/processing/ScriptRunning
/home/username/processing/functions/include_me

在脚本中,它会打开另一个脚本,它只包含一个函数:

#!/bin/bash
#This is ScriptRunning script
. functions/include_me

现在,当我使用以下nohup命令调用脚本时:

nohup / home / username / processing / ScriptRunning

这是输出:

/home/username/processing/ScriptRunning: line 3: /home/username/functions/include_me: No such file or directory

似乎错过了processing目录

我已修改ScriptRunning中的行以获得完整路径,两者都硬编码为/home/username/processing,并将此作为通过调用$(pwd)创建的变量,但错误是同样的。

我真的错过了一些如此愚蠢的东西吗?

1 个答案:

答案 0 :(得分:1)

这不是nohup问题。您使用相对文件名包含源文件。尝试:

. $(dirname ${BASH_SOURCE})/functions/include_me

包含相对于${BASH_SOURCE}

的源文件
相关问题