Reputation: 4605
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
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