source: tags/Mars-V1.2/datacenter/scripts/zipscript

Last change on this file was 8482, checked in by Daniela Dorner, 18 years ago
*** empty log message ***
  • Property svn:executable set to *
File size: 3.4 KB
Line 
1#!/bin/sh
2#
3# ========================================================================
4#
5# *
6# * This file is part of MARS, the MAGIC Analysis and Reconstruction
7# * Software. It is distributed to you in the hope that it can be a useful
8# * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
9# * It is distributed WITHOUT ANY WARRANTY.
10# *
11# * Permission to use, copy, modify and distribute this software and its
12# * documentation for any purpose is hereby granted without fee,
13# * provided that the above copyright notice appear in all copies and
14# * that both that copyright notice and this permission notice appear
15# * in supporting documentation. It is provided "as is" without express
16# * or implied warranty.
17# *
18#
19#
20# Author(s): Daniela Dorner 09/2006 <mailto:dorner@astro.uni-wuerzburg.de>
21#
22# Copyright: MAGIC Software Development, 2000-2007
23#
24#
25# ========================================================================
26#
27# This script zips the incoming rawfiles.
28#
29
30source `dirname $0`/sourcefile
31printprocesslog "INFO starting $0"
32# to give the possibility to run several zipscripts at the same time,
33# $1 is added
34program=zipscript$1
35
36set -C
37
38rawdatapath=$datapath/rawfiles
39files=`find $rawdatapath -type f -name '*.raw'`
40
41scriptlog=$runlogpath/$program-$datetime.log
42date >> $scriptlog 2>&1
43
44# check if script is already running
45lockfile=$lockpath/lock-$program.txt
46checklock >> $scriptlog 2>&1
47
48
49if [ "$files" == "" ]
50then
51 echo "no files to zip" >> $scriptlog 2>&1
52 finish >> $scriptlog 2>&1
53fi
54
55for file in ${files[@]}
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
84 echo "zipping $file ..." >> $scriptlog 2>&1
85 if ssh -x phoenix nice -n 19 gzip -1f $file >> $scriptlog 2>&1
86 then
87 gzfile=$file".gz"
88 chmod a-w $gzfile >> $scriptlog 2>&1
89 else
90 printprocesslog "WARN zipping $file did not work"
91 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
103done
104
105lockfile=$lockpath/lock-$program.txt
106finish >> $scriptlog 2>&1
107
Note: See TracBrowser for help on using the repository browser.