Skip to content
Snippets Groups Projects
it4s1_wait_for.sh 1.1 KiB
Newer Older
  • Learn to ignore specific revisions
  • Milan Lazecky's avatar
    Milan Lazecky committed
    #!/bin/bash
    #This script waits to get some processing done, i.e. after a $FILE (finished) is created
    #Second parameter will do the opposite - will create a file and wait until "someone" will delete it..
    if [ -z $1 ]; then
     echo "Helping script to wait until given FILE is created. It will be removed afterwards."
     echo "Second parameter will do opposite - it will create a file and will wait until his removal."
     echo "Usage: "`basename $0`" FILE_to_finish [file_in_ISCESERVER_processing]"
     echo "  e.g. "`basename $0`" /path/to/finished [/path/to/isceserv_processing]"
     exit
    fi
    
    FILE=$1
    if [ ! -z $2 ]; then ISCESER=$2; touch $ISCESER; fi
    
    Milan Lazecky's avatar
    Milan Lazecky committed
    MUJLOGIN=`whoami`
    
    Milan Lazecky's avatar
    Milan Lazecky committed
    
    echo "Waiting started at:"
    date
    echo "-------------"
    if [ ! -z $ISCESER ]; then
     echo "..first waiting for ISCE server processing."
     while [ -f $ISCESER ]; do sleep 10; done
     echo "ISCE server processing finished at"
     date
     echo "-------------"
    fi
    while [ ! -f $FILE ]; do
    
    Milan Lazecky's avatar
    Milan Lazecky committed
     if [ `qstat | grep $MUJLOGIN | wc -l` -lt 1 ]; then echo "Processing not finished but there is nothing in queue :("; date; exit; fi
    
    Milan Lazecky's avatar
    Milan Lazecky committed
     sleep 10
    done
    echo "done. Finished at:"
    date
    echo ""
    
    Milan Lazecky's avatar
    Milan Lazecky committed
    rm $FILE