user1654183
user1654183

Reputation: 4605

Job chaining with qsub

I have a python script which does some stuff to an input-file and then submits a new job using qsub.

As soon as this new submitted job has finished, I want to run the python script again. So basically, the running of this python script has to be linked to the running of the previous job, which the python script itself submitted.

To summarise in code terms. I go into a parent directory and type:

./python_script.py

The python script is structured something like follows (it's much, much more complicated in reality):

def Main():
    subdirectory = IdentifySubDirectory()
    os.chdir(subdirectory)
    EditInputFile()
    qsub jobscript.sh
    os.chdir(parentdirectory)

How can I do this just using my python script and a jobscript?

Previously I have been using crontab and running it every x hours, but this is an extremely unsatisfactory situation because each simulation takes a different amount of time to run resulting in a lot of dead-time.

Thanks for any help

Upvotes: 1

Views: 734

Answers (2)

Dave X
Dave X

Reputation: 5157

Have your job script re-submit itself:

jobscript.bash:

#!/bin/bash
cd $PBS_O_WORKDIR
./pythonscript.py
qsub -N reiterateSim jobscript.bash 

Upvotes: 0

dbeer
dbeer

Reputation: 7213

If this is TORQUE you can use job dependencies to get the behavior you're describing. Job dependency submissions are documented here, just do a find on the word depend and it'll take you right to it.

Upvotes: 1

Related Questions