gpt4 book ai didi

bash - 我如何判断 PBS 脚本是否被 bash 或 qsub 调用

转载 作者:行者123 更新时间:2023-11-29 09:47:51 24 4
gpt4 key购买 nike

我有一个处理多个环境变量的 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/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com