Ignore:
Timestamp:
12/13/06 17:23:40 (18 years ago)
Author:
snruegam
Message:
*** empty log message ***
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/datacenter/scripts/movingrawfiles

    r7944 r8234  
    2525# ========================================================================
    2626#
    27 # This script is moving the rawfiles from the directory 
    28 # /magic/datacenter/fromtape/rawdata to the structure 
     27# This script is moving the rawfiles from the directory
     28# /magic/datacenter/fromtape/rawdata to the structure
    2929# /magic/data/rawfiles/YYYY/MM/DD
    3030#
     
    4040date >> $scriptlog 2>&1
    4141
    42 # check if script is already running
     42# check whether script is already running
    4343lockfile=$lockpath/lock-$program.txt
    4444checklock  >> $scriptlog 2>&1
    4545
    46 # change permission for files 
     46# change permission for files
    4747ssh tape@dc07 chmod -R g+w /magic/datacenter/fromtape/rawdata/* >> $scriptlog 2>&1
    4848# output for chmod with -v or -c (only changes)
    4949
    5050printprocesslog "INFO moving directories from fromlapalma to fromtape"
    51 #find directories, which have to be copied
     51#find directories which have to be copied
    5252dirs=`ls /magic/datacenter/fromlapalma/RAWchk/*/*.finished | sed -e 's/RAWchk/RAW/g' | cut -d/ -f1-6`
    5353if [ ! "$dirs" == "" ]
    5454then
    55    # change permission for this dirctories
    56    ssh lapalma@apollo chmod -R g+w $dirs >> $scriptlog 2>&1
    57    # move directories to the tapedirectory
    58    mv -v $dirs /magic/datacenter/fromtape/rawdata/ >> $scriptlog 2>&1
     55   for dir in $dirs
     56   do
     57      # get number of *.raw files from directory
     58      numfiles=`find $dir -type f -name "*.raw" | wc -l`
     59     
     60      # skip empty directories
     61      if [ "$numfiles" == "0" ]
     62      then
     63         continue
     64      fi
     65
     66      # get date from directory name
     67      curdate=`echo $dir | cut -d/ -f6- | sed -e 's/_/-/g'`
     68     
     69      getdbsetup
     70      # get number of runs on this date from db
     71      query="select COUNT(*) from RunData where ADDDATE(fRunStart, Interval 12 hour) like '$curdate %'"
     72
     73      if ! numruns=`mysql -s -u $us --password=$pw --host=hercules $db -e "$query" | tail -1`
     74      then
     75         echo "ERROR could not query number of runs from rundb -> continue" >> $scriptlog 2>&1
     76         printprocesslog "ERROR could not query number of runs for $curdate from rundb"
     77         continue
     78      fi
     79
     80      # Check if number of runs matches. If not, skip this directory
     81      if ! [ $numfiles -eq $numruns ]
     82      then
     83         echo "WARNING" >> $scriptlog 2>&1
     84         echo "Expecting $numruns raw-files for $curdate but found only $numfiles" >> $scriptlog 2>&1
     85         continue
     86      fi
     87
     88      # check for non-raw-files
     89      nonraw=`find $dir -type f ! -name "*.raw"`
     90      if [ ! "$nonraw" == "" ]
     91      then
     92         echo "non-raw-files found in $dir" >> $scriptlog 2>&1
     93         printprocesslog "WARNING non-raw-files found in $dir"
     94      fi
     95
     96      # change permission for this directory
     97      ssh lapalma@apollo chmod -R g+w $dir >> $scriptlog 2>&1
     98      # move directories to the tapedirectory
     99      mv -v $dir /magic/datacenter/fromtape/rawdata/ >> $scriptlog 2>&1
     100
     101   done
    59102fi
    60103
Note: See TracChangeset for help on using the changeset viewer.