#!/usr/bin/env bash export VERBOSE=0 ; if [ .$1 != "." ] ; then export VERBOSE=$1 ; fi # cleanup procedure lockfile=$HOME/lock/cleanup.lock export VAL_DIR=/cdf/scratch/cdfopr/val list_of_requests=`ls $VAL_DIR/book/requests/* | grep -v save | grep -v tmp` stream=a touch $lockfile # # find the existing logfiles, assume theat these are from the aborted jobs # list_of_aborted_files=`ls $VAL_DIR/results/*.s.log | \ sed 's/.s.log//' | \ awk -F / '{print $NF}' | sed 's/^aa/ar/' ` if [ $VERBOSE != 0 ] ; then echo ...ABORTED: $list_of_aborted_files ; fi for file in $list_of_aborted_files ; do # # loop over the requests, each file can be only listed in one request # if [ $VERBOSE != 0 ] ; then echo ...ABORTED FILE $file ; fi export FILE=$file for request in $list_of_requests ; do x=`cat $request | grep $file` if [ $VERBOSE != 0 ] ; then echo processing request file $request .x.=.$x.; fi if [ ."$x" != "." ] ; then xx=`cat $request | grep $file | grep running` if [ ."$xx" != "." ] ; then cat $request | awk \ '{ if ($2 == ENVIRON["FILE"]) { if ($3 == "running") { $3 = "no" } } print $0 }' > $request.tmp if [ $VERBOSE != 0 ] ; then echo ---------------------------------------------- $request.tmp cat $request.tmp echo ---------------------------------------------- fi mv $request.tmp $request else echo ERROR: $file already DONE in $request. fi fi done done cleanup_list=`ls $VAL_DIR/results | grep aa | grep phys.s` if [ $VERBOSE != 0 ] ; then echo ...CLEANUP_LIST: $cleanup_list ; fi for file in $cleanup_list ; do rm $VAL_DIR/results/$file done rm $lockfile exit