Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to print by echo the following "still in process wait another 10 min" every 10 min

Please advice what condition needs to add before the echo command in order to print this line every 10 min?

Remark - counter increase by one every cycle (1 second) , I not want to add Additional delay ( sleep command ) to this script !!!!!

 Until   [    ]

 sleep 1

  let counter=$counter+1

  [ .... ] &&  echo " still in process wait another 10 min …."

share|improve this question
up vote 1 down vote accepted

Add another counter, and if that reaches 600, call echo and reset the counter. Repeat as needed.

So something like this should do:

let echocounter=$echocounter+1
if [ $echocounter == 600 ]; then echo "still in process wait 10 min ..."; $echocounter=0; fi
share|improve this answer
Just remove the $ before echocounter ( $echocounter=0; fi not ilegal in bash) – yael Jun 11 '12 at 13:26
+1 this is what i would have suggested. take loop until counter is 600, then echo thing and reset counter to 0. however, from faker's answer, i realize mod is much more elegant and efficient – acolyte Jun 11 '12 at 13:55

Use the modulo operator (bash specific syntax):

if [ $(($counter % 600)) -eq 0 ] ; then
  echo " still in process wait another 10 min .."

Or more portable:

if [ `expr $counter % 600` -eq 0 ] ; then
  echo " still in process wait another 10 min .."
share|improve this answer
Aieeee! Should have thought this.... +1 to you, sir! – Janne Pikkarainen Jun 11 '12 at 13:28

What you want, is something like this:

#10 minutes from now
Increment_Timestamp=$(( $(date +%s) + 600 ))

while [  ...  ]
    # When now is 10 minutes ago, show the message.
    if [ $(date +%s) -lt "${Increment_Timestamp}" ]
        ${Increment_Timestamp}=$(( $(date +%s) + 600 ))
        echo "Message"
share|improve this answer

I added some logic to check the time:

MINUTES=$(date +"%M")
MINUTES=$(echo $MINUTES | sed 's/^0*//')

if $BOOL ; then

        if [ $MINUTES -le "49" ];then

if [ $MINUTES10 -eq $MINUTES ];then
        echo "message"
share|improve this answer
hi - I not want to add another delay to my script ( not want to add another sleep ) – yael Jun 11 '12 at 12:35
Next time provide a bit more information what you want, your question is not really clear. So you want to do process X and every ten minutes you want to print the message if the script hasnt finished? – Lucas Kauffman Jun 11 '12 at 12:40
yes I want to create condition - see my comment in my question – yael Jun 11 '12 at 12:41

You probably want the sleepenh program, which allows for "accurate sleeping". There's also a blog post about how it was used to solve a problem which required no oversleeping

share|improve this answer

Your Answer


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.