bash - 如何判断 PBS 脚本是由 bash 还是 qsub 调用

标签 bash pbs

我有一个处理多个环境变量的 PBS 脚本。 PBS 是 bash 的包装器,它将 bash 脚本发送到作业调度队列。处理后的变量形成一个命令来运行 scientific application 。 PBS 脚本是用 bash 编写的,并在 bash 注释中编码了作业调度程序的附加信息。

如何以编程方式确定我的脚本是否由 qsub(解释 PBS 脚本的命令)调用,或者是否由 bash 调用?

如果脚本在 bash 下运行,我想将调用视为试运行,并且只打印生成的命令。这样它就完全绕过了作业队列。

最佳答案

这可能并不完全可靠,但一种可能有效的启发式方法是测试以下任何环境变量是否存在,这些变量往往在 qsub 下定义,如列出的 here .

PBS_O_HOST (the name of the host upon which the qsub command is running)
PBS_SERVER (the hostname of the pbs_server which qsub submits the job to)
PBS_O_QUEUE (the name of the original queue to which the job was submitted)
PBS_O_WORKDIR (the absolute path of the current working directory of the qsub command)
PBS_ARRAYID (each member of a job array is assigned a unique identifier)
PBS_ENVIRONMENT (set to PBS_BATCH to indicate the job is a batch job, or to PBS_INTERACTIVE to indicate the job is a PBS interactive job)
PBS_JOBID (the job identifier assigned to the job by the batch system)
PBS_JOBNAME (the job name supplied by the user)
PBS_NODEFILE (the name of the file contain the list of nodes assigned to the job)
PBS_QUEUE (the name of the queue from which the job was executed from)
PBS_WALLTIME (the walltime requested by the user or default walltime allotted by the scheduler)

关于bash - 如何判断 PBS 脚本是由 bash 还是 qsub 调用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23987494/

相关文章:

bash - Unix - 按文件名过滤查找结果

linux - 如何使用 FIND 递归备份多个颠覆存储库

bash - 将 mysql 转储文件重命名为当前日期,然后对其进行 gzip

linux - 如何比较两个目录的大小?

bash - 立即发现并非所有环境变量都已在 qsub 命令行上定义

pbs - 请求节点的所有处理器

hpc - 同时执行多个 qsub 命令

linux - 一次创建一个完整的目录树

PBS 中给定 shell 的 Linux echo cpu(核心)名称/编号

pbs - PBS 批处理系统是否跨节点移动多个串行作业?