Working with High Performance Computing (HPC) servers, I always need to submit sequential jobs or jobs with dependency. So, the job you submit stays on queue and waits for the running job to finish. I use the following command:

for example, if the running job id is 4321234, and you would like to submit myrun.qsub, the command will look like:

But sometimes you have tens of jobs you want to submit all at once. Here is a bash code you can use to submit a chain of jobs:

You can run the code above using the following command in Linux command line:

and one last point! You can set the condition in which the next job will run, simply by changing afterany in the commands above. These are the options: