0

I am using Redhat and a pbs queuing system to submit jobs to finite element analysis code. I typically have a folder that contains a .dat file, which is what I want to run, and a .pbs file that will submit the .dat file. To submit the .dat file I would run the command "qsub *.pbs" in the directory containing both files.

How could I submit or just run "qsub *.pbs" from outside of the directories containing the .dat files. I would typically be two directories up from the .dat files.

Thanks

Benner145
  • 1
  • 2

1 Answers1

1

You could do a find and exec

find /tmp/foo -name "*.pbs" -exec qsub {} \;

Here is a test that I ran

[spuder@moab tmp]$ mkdir /tmp/torqueFun
[spuder@moab tmp]$ cd !$
[spuder@moab torqueFun]$ touch foo.pbs
[spuder@moab torqueFun]$ touch bar.pbs
[spuder@moab torqueFun]$ touch foobar.pbs

[spuder@moab torqueFun]$ find . -name "*.pbs" -exec qsub {} \;
19185.moab.novalocal
19186.moab.novalocal
19187.moab.novalocal
spuder
  • 17,437
  • 19
  • 87
  • 153
  • How do I actually run the pbs files in their respective directories rather than in the directory this command was executed in? – Ben Apr 03 '15 at 07:38
  • The command `find .` will search the current directory. You could search any folder like this: `find /some/directory`. – spuder Apr 03 '15 at 15:08
  • I think you are misunderstanding my question. If I say go the parent folder and execute the command that you wrote. Then, like I wanted, it goes into each subdirectory and executes each PBS file. However, the pbs files get executed in the parent directory and not the subdirectories. All my subdirectories have different names. I Was not sure how I can remedy this, either with editing the command you sent, or editing my pbs files. Note I have 20 subdirectories and each has a different pbs file. – Ben Apr 03 '15 at 16:25
  • Is what I'm saying making sense? Let's say I am in parent directory called "A" and I have subdirectories, "1t" through "20t" When I am in parent directory "A" and execute command, it actually tries to run the pbs files from each subdirectory, but runs them in the parent directory where the input scripts are not located, which results in a lot of error files. – Ben Apr 03 '15 at 16:51
  • You could try `cd-ing` into each directory that it finds a .pbs file then `cd-ing` back out. Or you could try overwriting the PWD environment variable. If that doesn't help, then you probably should open a new stack overflow question. – spuder Apr 03 '15 at 17:14