Ignore:
Timestamp:
05/09/07 17:05:15 (18 years ago)
Author:
Daniela Dorner
Message:
*** empty log message ***
File:
1 edited

Legend:

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

    r8331 r8482  
    2020#   Author(s): Daniela Dorner  09/2006 <mailto:dorner@astro.uni-wuerzburg.de>
    2121#
    22 #   Copyright: MAGIC Software Development, 2000-2006
     22#   Copyright: MAGIC Software Development, 2000-2007
    2323#
    2424#
     
    3030source `dirname $0`/sourcefile
    3131printprocesslog "INFO starting $0"
    32 program=zipscript
     32# to give the possibility to run several zipscripts at the same time,
     33# $1 is added
     34program=zipscript$1
    3335
    3436set -C
     
    5254
    5355for file in ${files[@]}
    54 do
     56do
     57   echo "processing file $file..." >> $scriptlog 2>&1
     58   runno=`basename $file | cut -d_ -f2`
     59   query="SELECT fSequenceFirst FROM RunData WHERE fRunNumber="$runno
     60   echo " sending query: $query" >> $scriptlog 2>&1
     61   if ! seq=`sendquery`
     62   then
     63      echo "querying seq for run $runno from the db did not work -> continue" >> $scriptlog 2>&1
     64      printprocesslog "WARN query $seq for run $runno from the db did not work"
     65      continue
     66   fi
     67   if [ "$seq" == "" ]
     68   then
     69      echo "no seq found for run $runno -> locking only run..." >> $scriptlog 2>&1
     70      seq=$runno
     71   fi
     72   echo "locking sequence $seq..."  >> $scriptlog 2>&1
     73   lockfile=$lockpath/calzip$seq.txt
     74   checklock continue >> $scriptlog 2>&1
     75   query="UPDATE SequenceProcessStatus set fNotZipping=NULL WHERE fSequenceFirst=$seq"
     76   echo " sending query: $query" >> $scriptlog 2>&1
     77   if ! sendquery
     78   then
     79      echo "locking $seq for callisto in db did not work ..." >> $scriptlog 2>&1
     80      printprocesslog "WARN locking $seq for callisto in db did not work"
     81      rm -v $lockfile >> $scriptlog 2>&1
     82      continue
     83   fi
    5584   echo "zipping $file ..." >> $scriptlog 2>&1
    56 #   if ssh pegasus nice -n 19 gzip -1f $file >> $scriptlog 2>&1
    57    if ssh phoenix nice -n 19 gzip -1f $file >> $scriptlog 2>&1
    58 
     85   if ssh -x phoenix nice -n 19 gzip -1f $file >> $scriptlog 2>&1
    5986   then
    60       chmod a-w $file >> $scriptlog 2>&1
     87      gzfile=$file".gz"
     88      chmod a-w $gzfile >> $scriptlog 2>&1
     89   else
     90      printprocesslog "WARN zipping $file did not work"
    6191   fi
     92   echo "unlocking sequence $seq..."  >> $scriptlog 2>&1
     93   query="UPDATE SequenceProcessStatus set fNotZipping=Now() WHERE fSequenceFirst=$seq"
     94   echo " sending query: $query" >> $scriptlog 2>&1
     95   if ! sendquery
     96   then
     97      echo "unlocking $seq for callisto in db did not work ..." >> $scriptlog 2>&1
     98      printprocesslog "ERROR unlocking $seq for callisto in db did not work"
     99      rm -v $lockfile >> $scriptlog 2>&1
     100      continue
     101   fi
     102   rm -v $lockfile >> $scriptlog 2>&1
    62103done
    63104
     105lockfile=$lockpath/lock-$program.txt
    64106finish >> $scriptlog 2>&1
    65107
    66 
    67 
    68 # old code for running script locally
    69 
    70 #rawdatapath=$datapath/rawfiles
    71 ##h:     0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
    72 #pnos=( 2 2 2 2 2 2 2 2 2 2  2  2  2  2  2  2  2  2  2  2  2  2  2  2 )
    73 #sl1=30 #sleeping time before new directory
    74 #sl2=60 #sleeping time before new process check
    75 #
    76 #dirs=`find $rawdatapath -type d | grep -v timecorrlogs | sort`
    77 ##dirs=`find $rawdatapath -type d | grep -v timecorrlogs | sort -r`
    78 #
    79 #for dir in ${dirs[@]}
    80 #do
    81 #   cont=`echo $dir | cut -d/ -f7`
    82 #   if [ "$cont" == "" ]
    83 #   then
    84 #      continue
    85 #   fi
    86 #
    87 #   if ! ls $dir/*.raw >/dev/null 2>&1
    88 #   then
    89 #      echo "no unzipped rawfiles in $dir left"
    90 #      continue
    91 #   fi
    92 #
    93 #   echo "sleeping $sl1..."
    94 #   sleep $sl1
    95 #
    96 #   h=`date +%k`
    97 #   count=`ps aux | grep gzip | grep -v grep | wc -l`
    98 #   echo "count: $count - h: $h - pno: ${pnos[$h]}"
    99 #   while [ "$count" -ge "${pnos[$h]}" ]
    100 #   do
    101 #      echo "sleeping $sl2..."
    102 #      sleep $sl2
    103 #      h=`date +%k`
    104 #      count=`ps aux | grep gzip | grep -v grep | wc -l`
    105 #      echo "count: $count - h: $h - pno: ${pnos[$h]}"
    106 #   done
    107 #   echo $dir
    108 #   du -hs $dir
    109 #   echo "gzip -1f $dir/*.raw &"
    110 #   gzip -1f $dir/*.raw &
    111 #done
    112 #
    113 
    114 
    115 # old code for running script with condor
    116 
    117 #rawdatapath=$datapath/rawfiles
    118 ##h:     0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
    119 #pnos=( 2 2 2 2 2 2 2 2 2 2  2  2  2  2  2  2  2  2  2  2  2  2  2  2 )
    120 #sl1=30 #sleeping time before new directory
    121 #sl2=60 #sleeping time before new process check
    122 #
    123 #dirs=`find $rawdatapath -type d | grep -v timecorrlogs | sort`
    124 ##dirs=`find $rawdatapath -type d | grep -v timecorrlogs | sort -r`
    125 #
    126 #for dir in ${dirs[@]}
    127 #do
    128 #   cont=`echo $dir | cut -d/ -f7`
    129 #   if [ "$cont" == "" ]
    130 #   then
    131 #      continue
    132 #   fi
    133 #
    134 #   if ! ls $dir/*.raw >/dev/null 2>&1
    135 #   then
    136 #      echo "no unzipped rawfiles in $dir left"
    137 #      continue
    138 #   fi
    139 #
    140 #   echo "sleeping $sl1..."
    141 #   sleep $sl1
    142 #
    143 #   h=`date +%k`
    144 #   count=`grep gzip .condor_run.* | wc -l`
    145 #   echo "count: $count - h: $h - pno: ${pnos[$h]}"
    146 #   while [ "$count" -ge "${pnos[$h]}" ]
    147 #   do
    148 #      echo "sleeping $sl2..."
    149 #      sleep $sl2
    150 #      h=`date +%k`
    151 #      count=`grep gzip .condor_run.* | wc -l`
    152 #      echo "count: $count - h: $h - pno: ${pnos[$h]}"
    153 #   done
    154 #   echo $dir
    155 #   du -hs $dir
    156 #   condor_run gzip -1f $dir/*.raw &
    157 #
    158 #done
    159 #
    160 
Note: See TracChangeset for help on using the changeset viewer.