集群使用Loadleveler调度作业。我希望循环仅在当前迭代中提交的作业完成后才开始下一个迭代。
我知道可以使用wait
来做到这一点,但我不知道如何做。任何帮助表示赞赏。
#!/bin/bash
for i in 1 2 3
do
submit job
retrieve job id
check if the submitted job is over so the next iteration of for can start
done
答案 0 :(得分:0)
这是一小段代码,可以为您提供帮助。
#!/bin/bash
total_attempts=0
for attempt in 1 2 3;
do
echo attempt $attempt #Use your submit job here
# initialise stuff
counter=0 #Use your retrieve_job_id here
# since the next step is to check, we first need to retrieve state.
rand=$((RANDOM)) #Use your get_job_state here
# Check we didn't reach completion
while [ $rand -gt 2000 ]; #Use your criterium here
do
# You probably want to change the following lines...
echo $rand; #You don't want this line, but it'll help you understand what's going on
# get new state
rand=$((RANDOM)); #Use your get_job_state here
counter=$((counter+1))
done
#At this line, the criterium has been met for the attempt.
echo attempt $attempt got $rand ! #You don't want this line, but it'll help you understand what's going on
# A job has been completed, so maybe we need to clean stuff up.
total_attempts=$((total_attempts+counter)) #Use your imagination here :)
done
echo $total_attempts attempts required to finish 3 jobs.