Syntax for submitting a qsub job without an actual job file?

孤者浪人 提交于 2019-12-08 01:32:05

问题


I would like to submit qsub jobs on the fly without creating discrete job files. So, let's say I have a python script called "get_time.py" that simply reports the time. Instead of making a submission script like this:

cat>job.sub<<eof
    #PBS -l walltime=1:00:00
    cd $PBS_O_WORKDIR
    get_time.py
eof

...and then submitting the job: qsub job.sub

I would like to be able to bypass the file creation step, and I'd image the construct would be something like this: qsub -d . -e get_time.py

where -e is my imaginary parameter that tells qsub that the following is code to be sent to the scheduler, instead of using a discrete submission file.

Am I crazy? It seems like there should already be a simple solution for this, but I couldn't find it anywhere. Thanks for any suggestions!


回答1:


You can pass the name of any executable script/file to qsub after you've provided all your options (-d ., etc.). Any arguments that come after the script name are treated as arguments for that script. For example, if I had the script test.py:

#!/usr/bin/python
from sys import argv
script, param = argv
print param

Then I can run

qsub test.py 2

and the output to my log will be 2.

Two important things to note:

  1. Your Python script must be executable (e.g. chmod +x test.py).
  2. Your Python script must have a shebang (e.g. #!/usr/bin/python).



回答2:


If you are ok with writing your job in a HERE document, as in your example, you can pass that HERE doc directly to qsub without a temporary file:

qsub <<eof
    #PBS -l walltime=1:00:00
    cd \$PBS_O_WORKDIR
    get_time.py
eof

Also note that you need to escape the dollar sign in $PBS_O_WORKDIR or else it will be interpolated before submitting the job and end up as an empty string.




回答3:


In grid engine, -b y specifies that the thing to be executed is a binary, not a script:

qsub -b y get_time.py



回答4:


I don't understand the question but...

echo 'date' | qsub

is not working well for you?




回答5:


Provided get_time.py is executable, and the shebang is correct, you should be able to simply run

qsub -d . get_time.py

If that fails for either reason, you can use the following construct

qsub -d . <<< "python get_time.py"


来源:https://stackoverflow.com/questions/20127722/syntax-for-submitting-a-qsub-job-without-an-actual-job-file

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!