假设我创建了一个如下所示的Python PBS文件提交:
!/usr/bin/python
# Example PBS cluster job submission in Python
from popen2 import popen2
import time
#PBS -M email
#PBS -m abe # (a = abort, b = begin, e = end)
# Loop over your jobs
for i in range(1, 10):
# Open a pipe to the qsub command.
output, input = popen2('qsub')
# Customize your options here
job_name = "job%s" % str(i).zfill(3)
walltime = "24:00:00"
processors = "nodes=1:ppn=1"
command = "./file%s" % str(i).zfill(3)
job_string = """#!/bin/bash
#PBS -N %s
#PBS -l walltime=%s
#PBS -l %s
#PBS -o ./output/%s.out
#PBS -e ./error/%s.err
cd $PBS_O_WORKDIR
%s""" % (job_name, walltime, processors, job_name, job_name, command)
# Send job_string to qsub
input.write(job_string)
input.close()
# Print your job and the response to the screen
print job_string
print output.read()
time.sleep(0.1)
我在Unix系统上用Python执行这段代码。我想知道,在提交每个PBS文件时,是否可以在file1.py
,file2.py
中进行更改?每个file%s.py
中都有一个变量date
(ex date='2010-01-20'
),每次提交新的PBS批处理文件时,我都希望对其进行更改。这可以在上面的代码中启动,而无需在每个file1.py
,file2.py
中手动更改日期......?