Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I have this bash script;

for (( i = 1 ; i <= 160 ; i++ )); do
  qsub myccomputations"${i}".pbs
done

Basically, I would prefer if there was a 1 second delay between each iteration. The reason is that at each iterations, it sends the program file mycomputation"${i}$.pbs to a core node for solving.

Solving in this instance involves the use of pseudo random numbers. I suspect that the RNG I use (R's) uses CPU time as seed because as things are now I get repeating pseudo random numbers (at the rate of approximately 1 out of 100).

So how to you ask bash to

for (( i = 1 ; i <= 160 ; i++ )); do
  wait 1 sec    
  qsub myccomputations"${i}".pbs
done
share|improve this question
add comment

2 Answers

up vote 12 down vote accepted

Simply use sleep 1 in Bash.

for (( i = 1 ; i <= 160 ; i++ )); do
  sleep 1
  qsub myccomputations"${i}".pbs
done
share|improve this answer
    
thanks! i hope it will solve that RNG problem...best –  user2413 Feb 17 '11 at 14:46
    
you can use floating point number if you want to sleep less than 1 second –  shellholic Feb 17 '11 at 14:49
add comment

If you want to achieve what your topic suggests, you should use 'at'.

See

      man at

for more information.

share|improve this answer
1  
thank you Olli. Indeed, i will rewrite the title, so it corresponds to the question, for future queries. –  user2413 Feb 17 '11 at 15:31
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.