使用 qsub 在另一个 bash 脚本中调用一个 bash 脚本

Calling a bash script inside another bash script using qsub

我正在尝试使用 qsub 运行 另一个 bash 脚本中的 bash 脚本(因为我需要 运行 集群上的实际问题)。

下面是这个问题的演示。我有两个脚本如下:

脚本 1:

#!/bin/bash -f
sh ./script2.sh

脚本 2:

#!/bin/bash
echo "It works fine!"

现在,如果我将这两个脚本放在一个文件夹中并使用命令 sh script1.sh,它将正常工作。但是如果我使用 qsub 命令 运行 宁它 qsub script1.sh 它会通过一个错误:

sh: ./script2.sh: 没有那个文件或目录

我该如何解决?

To define the working directory path to be used for the job -d option can be used. If it is not specified, the default working directory is the home directory.

检查您的工作目录。

#!/bin/bash -f
echo "Working directory is $PWD"
sh ./script2.sh

您可以使用 -d 选项来解决这个问题。

qsub -d <working directory> script1.sh