如何从Perl脚本确定它是通过SGE运行还是从命令行本地运行?确定脚本是否在SGE中运行
1
A
回答
4
从http://www.cbi.utsa.edu/sge_tutorial:
When a Sun Grid Engine job is run, a number of variables are preset into the
job’s script environment, as listed below.
SGE_ROOT - The Sun Grid Engine root directory as set for sge_execd before
start-up or the default /usr/SGE
SGE_CELL - The Sun Grid Engine cell in which the job executes
SGE_JOB_SPOOL_DIR - The directory used by sge_shepherd(8) to store jobrelated
data during job execution
...
...
检查%ENV应该告诉你,如果它是通过SGE运行。
0
你可以尝试这样的事情:
use Proc::ProcessTable;
my $running_under_sge = 0;
my $ppid = getppid();
my $t = new Proc::ProcessTable;
foreach my $p (@{$t->table}) {
if ($p->pid == $ppid) {
if ($p->cmdline =~ m/sge_shepherd/) {
$running_under_sge++;
last;
}
}
}
这是通过检查你的程序的父进程。如果父进程是sge_shepherd,那么它是由SGE exec守护进程启动的。根据您使用的Grid Engine版本,名称可能会有所不同。
0
jlp提供的脚本是一种彻底的检查方式,并且是我推荐的方式。虽然如果你想做一个简短的陈述来检查你是否有环境工作人员的工作证号。见下面的脚本。
#!/usr/bin/perl
use strict;
my $job_id = $ENV{JOB_ID};
if ($job_id > 0) {
print "Is and SGE job";
} else {
print "Is NOT and SGE job";
}
相关问题
- 1. 确定脚本是否在RStudio笔记本中运行
- 2. 完成sge作业后运行脚本
- 3. 确定脚本是否在pythonw中运行?
- 4. 如何确定我的python脚本是否正在运行?
- 5. 确定ruby脚本是否已经运行
- 6. 如何确定脚本是否以前使用Ansible运行?
- 7. 如何确定shell脚本是否以root权限运行?
- 8. 运行预脚本以确定是否应运行Jenkins矩阵作业
- 9. 通过Shell脚本确定Linux进程是否在给定参数下运行
- 10. PowerShell脚本是否在Mono下运行?
- 11. 确定进程是否正在运行?
- 12. 是否可以从脚本中确定r2build脚本的位置?
- 13. 如何使用wsadmin Jython脚本确定应用程序是否正在运行?
- 14. 使用shell子进程来确定第二个脚本是否仍在运行
- 15. 确定我是在Cloudhub上运行还是在本地运行
- 16. 如何确定我运行的PHP脚本是否是mod_rewrite指向的结果?
- 17. sge在脚本中获取脚本位置
- 18. 检查是否python脚本运行
- 19. 脚本来检查IIS是否运行
- 20. SGE脚本:在执行过程中打印到文件(不只是在最后)?
- 21. MRJob确定是否在线,本地,emr或hadoop运行
- 22. 在MSBuild中可以确定我是否在Visual Studio中运行
- 23. 这是在Python中运行shell脚本的正确方法吗?
- 24. 确定Google Apps脚本WebApp是以/ dev模式运行
- 25. 如何确定在脚本引擎中运行的Groovy代码中是否存在变量?
- 26. 是否可以在WLST中运行脚本?
- 27. 检查两个进程是否未在shell脚本中运行
- 28. 我如何知道脚本是否在iframe中运行
- 29. autohotkey是否可以在自己的脚本中写入运行?
- 30. 如何检查是否在PowerShell中运行时通过脚本
其中一些变量存在于我的登录shell环境中。 'SGE_JOB_SPOOL_DIR'似乎不在那里,所以我会去那,谢谢。 – ajwood 2011-03-14 16:06:58