Waiting a job to finish


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Waiting a job to finish
# 1  
Old 04-05-2013
Waiting a job to finish

Hello again,

I am runnning a job on a cluster and I submit a job with the command

Code:
qsub script.sh

where script.sh is a script with the command i want o use. When i enter this command the cluster gives a huber like 123456 as the JOB ID.

I want the job to run about 12 hours and when it stops a new job will be submitted to the cluster. So what i do is creating a new script which includes the following:

Code:
for dir in $(seq 1 1 2)
do

msub script.sh

wait 123456 

done

but it fails waiting the job to finish and instead gives two jobs to the cluster.

Is it possible to do this?

Last edited by jim mcnamara; 04-06-2013 at 08:06 PM..
# 2  
Old 04-05-2013
Why not create a batch (*.bat) file such that once the first job finishes, the next one resumes?
This User Gave Thanks to kayak For This Post:
# 3  
Old 04-05-2013
thanks kayak for the answer but can you be more specific since I am new to this.. thank you
# 4  
Old 04-06-2013
Please use code tags as required by forum rules!

If you hard code the number following wait, it will usually fail. Either use wait without a number, or find the process ID of your job and give this to wait.

man bash (not sure if you're using bash?):
Quote:
wait [n ...]
Wait for each specified process and return its termination status. Each n may be a process ID or a job specification; if a
job spec is given, all processes in that job's pipeline are waited for. If n is not given, all currently active child pro‐
cesses are waited for, and the return status is zero. If n specifies a non-existent process or job, the return status is
127. Otherwise, the return status is the exit status of the last process or job waited for.
# 5  
Old 04-07-2013
wait is for shells with job control. Where jobs are local processes.
But "cluster" certainly means there a software that distributes the processes to other systems.
Then I can only recommend to consult the cluster software documentation that also describes the qsub and msub commands. There is certainly a "Queue-query" command...
# 6  
Old 04-07-2013
Assuming this is referring to the qsub utility that is specified by the POSIX standards (although few implementations provide the optional POSIX Batch Environment Services and Utilities features), wait won't work. The qsub utility submits a job to be executed on a remote server and returns as soon as the job is queued on that server. Normally, the server running the job will send mail to the submitter when the job completes.

There are a few ways to do what I think you're trying to do. One way is to periodically run a qstat command with operands being the job IDs that the calls to the qsub utility returned for the jobs they submitted. You would then have to parse the qstat output to determine when a job completes and at that point kick off another qsub to replace the completed job on that server.

Another way would be to have the last step executed by the job you submit with qsub be another qsub command that will queue a job on the server that submitted the original qsub and have that job kick of a replacement if work remains to be done.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Who can finish this script?

Good morning dear friends, I want to write an UNIX script to do the following task: We have 6 directories, called (SMS_01, SMS_02 ....... SMS_06), some files are distributed across these directories, but the distribution process is not good, I mean when I check these directories I found the... (14 Replies)
Discussion started by: Mohannad
14 Replies

2. Windows & DOS: Issues & Discussions

AutoSys Job not waiting for script to complete

I'm not sure if this is the right place to post this issue...but here goes... I am converting a set of windows jobs from Control-M to AutoSys r11.3. The same command line is being executed in both systems. The Control-M job runs to compltion in about 1.5 hours, waiting for the entire batch... (3 Replies)
Discussion started by: ajomarquez
3 Replies

3. Shell Programming and Scripting

Please help me to finish this scripts

Hi All, Can anyone help me to finish the scripts. this scripts is this scripts will run on crontab in every 4 minutes to get the newest router interface status. I would like to add a function to count the router interface flapping, if more than 2 times in 20 minutes (scripts run 5 times)... (1 Reply)
Discussion started by: momo0617
1 Replies

4. Shell Programming and Scripting

waiting on jobs in bash, allowing limited parallel jobs at one time, and then for all to finish

Hello, I am running GNU bash, version 3.2.39(1)-release (x86_64-pc-linux-gnu). I have a specific question pertaining to waiting on jobs run in sub-shells, based on the max number of parallel processes I want to allow, and then wait... (1 Reply)
Discussion started by: srao
1 Replies

5. Shell Programming and Scripting

Waiting for the background process to finish

Hi, I have on shell script which internally calls more than one scripts which run in background. These scripts cannot be modified to run in foreground. eg. myscript.sh -> bulk_launcher.sh -> acq_launcher.sh -> bulk_loader.sh I want the calling shell script myscript.sh to wait till the... (7 Replies)
Discussion started by: AB10
7 Replies

6. Shell Programming and Scripting

finish of file

Hello, I'm doing a script where I'm traveling a file, and moves down line by line, and is copied to another file, up to the line 100, then the smaller file passes to another format ... but the problem I have is that if there are 357 lines for example, file 1 2 i 3, converted correctly but the 4... (1 Reply)
Discussion started by: uri_crack
1 Replies

7. Shell Programming and Scripting

Finish script help

I am trying to add a finish script that can copy hosts, static routes and a few other files into relevant directories on a client system. These files would be mounted as nfs resource on the client as hosts.hostname, static_route.hostname etc. Script will compare the hostname of the client and copy... (0 Replies)
Discussion started by: c0kazaz
0 Replies

8. Shell Programming and Scripting

Waiting for a background process to finish

Hello, I am a novice shell script programmer. And facing this problem any help is appreciated. I m writing a shell script and running few commands in it background as I have to run them simultaneously. Sample code : sql_prog & sql_prog & sql_prog & echo "Process Completed" Here... (2 Replies)
Discussion started by: vineetbhati
2 Replies

9. UNIX for Advanced & Expert Users

commands do not finish

Hi, I have strange problem executing some command on solaris 5.9 ps command does not finish(hangs) and runs forever without any result. same with cc command too.Please suggest (1 Reply)
Discussion started by: Raom
1 Replies

10. UNIX for Dummies Questions & Answers

how do i finish this last one..

i tried to build a command to replaces the word "include" with "exclude" in each *.h type of file in a certain directory and to display the lines in which the switch happened. i did a command and i dont know why its not working find /usr -name "*.h" -exec sed 's/include/exclude/g' {} \;... (2 Replies)
Discussion started by: newby2
2 Replies
Login or Register to Ask a Question