source: trunk/MagicSoft/Mars/datacenter/scripts/filesondisk@ 8688

Last change on this file since 8688 was 8482, checked in by Daniela Dorner, 18 years ago
*** empty log message ***
  • Property svn:executable set to *
File size: 6.0 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 08/2004 <mailto:dorner@astro.uni-wuerzburg.de>
21#
22# Copyright: MAGIC Software Development, 2000-2007
23#
24#
25# ========================================================================
26#
27# This script checks which files are on disk and updates the database
28# accordingly. It is not yet running automatically.
29#
30# It is checking the:
31# - ccfiles
32# - cacofiles
33# this includes also the search for missing cacofiles:
34# Sometimes the DAQ aborts a run and starts itself a new one. In this
35# cases the camera control doesn't start a new file, as the command to
36# start a new run was not sent by the central control. So the caco
37# information is stored in the previous caco file, which has a
38# different runnumber. To be able to merpp the information into the
39# calibrated data file, the runnumber of the file containing the
40# information has to be found.
41# In this script the search and inserting into the database is done
42# using the macro findcacofiles.C
43# - rawfiles
44# The update in the database is done using the macro resetallruns.C
45#
46
47source `dirname $0`/sourcefile
48printprocesslog "INFO starting $0"
49program=filesondisk
50
51set -C
52
53scriptlog=$runlogpath/$program-$datetime.log
54date >> $scriptlog 2>&1
55
56# check if script is already running
57lockfile=$lockpath/lock-$program.txt
58checklock >> $scriptlog 2>&1
59
60filesondisklogpath=$logpath/$program/`date +%Y/%m`
61makedir $filesondisklogpath >> $scriptlog 2>&1
62
63cd $mars
64
65echo "checking disk for ccfiles..." >> $scriptlog 2>&1
66printprocesslog "INFO checking ccfiles"
67filename=$filesondisklogpath/ccfilesondisk-$datetime.txt
68if ls $filename >/dev/null 2>&1
69then
70 rm -v $filename >> $scriptlog 2>&1
71fi
72column=fCCFileAvail
73find $subsystempath/cc/ -name '*_S.rep' | cut -d_ -f2 > $filename
74
75echo "resetting runs..." >> $scriptlog 2>&1
76check3=`root -q -b $macrospath/resetallruns.C+\("\"$filename\""\,"\"$column\""\) | tee $filesondisklogpath/resetall-$column-$datetime.log | intgrep`
77
78case $check3 in
79 1) echo " check3=$check3 -> everything ok -> reset is done" >> $scriptlog 2>&1
80 printprocesslog "INFO ccfiles resetted successfully"
81 ;;
82 0) echo " check1=$check1 -> no connection to db -> continue..." >> $scriptlog 2>&1
83 printprocesslog "WARN connection to DB failed"
84 ;;
85 *) echo " check3=$check3 -> ERROR -> something went wrong while resetting" >> $scriptlog 2>&1
86 printprocesslog "ERROR resettallruns.C failed for ccfiles"
87 ;;
88esac
89
90
91
92echo "checking disk for cacofiles..." >> $scriptlog 2>&1
93printprocesslog "INFO checking cacofiles"
94filename=$filesondisklogpath/cacofilesondisk-$datetime.txt
95if ls $filename >/dev/null 2>&1
96then
97 rm -v $filename >> $scriptlog 2>&1
98fi
99column=fCaCoFileAvail
100find $subsystempath/caco/ -name '*.txt' | cut -d_ -f8 | grep [0-9] > $filename
101
102echo "resetting runs..." >> $scriptlog 2>&1
103check0=`root -q -b $macrospath/resetallruns.C+\("\"$filename\""\,"\"$column\""\) | tee $filesondisklogpath/resetall-$column-$datetime.log | intgrep`
104
105case $check0 in
106 1) echo " check0=$check0 -> everything ok -> reset is done" >> $scriptlog 2>&1
107 printprocesslog "INFO cacofiles resetted successfully"
108 ;;
109 0) echo " check1=$check1 -> no connection to db -> continue..." >> $scriptlog 2>&1
110 printprocesslog "WARN connection to DB failed"
111 ;;
112 *) echo " check0=$check0 -> ERROR -> something went wrong while resetting" >> $scriptlog 2>&1
113 printprocesslog "ERROR resettallruns.C failed for cacofiles"
114 ;;
115esac
116
117date=`date +%F`
118echo "finding missing cacofiles..." >> $scriptlog 2>&1
119printprocesslog "INFO checking missing cacofiles"
120check1=`root -q -b $macrospath/findcacofiles.C+ | tee $filesondisklogpath/findcacofiles-$datetime.log | intgrep`
121
122case $check1 in
123 1) echo " check1=$check1 -> everything ok -> missing cacofiles are found" >> $scriptlog 2>&1
124 printprocesslog "INFO missing cacofiles found"
125 ;;
126 0) echo " check1=$check1 -> no connection to db -> continue..." >> $scriptlog 2>&1
127 printprocesslog "WARN connection to DB failed"
128 ;;
129 *) echo " check1=$check1 -> ERROR -> something went wrong while resetting" >> $scriptlog 2>&1
130 printprocesslog "ERROR findcacofiles.C failed"
131 ;;
132esac
133
134
135
136echo "checking disk for rawfiles..." >> $scriptlog 2>&1
137printprocesslog "INFO checking rawfiles"
138filename=$filesondisklogpath/rawfilesondisk-$datetime.txt
139if ls $filename >/dev/null 2>&1
140then
141 rm -v $filename >> $scriptlog 2>&1
142fi
143column=fRawFileAvail
144find $datapath/rawfiles -name '*.raw' -o -name '*.gz' | cut -d_ -f2 > $filename
145
146echo "resetting runs..." >> $scriptlog 2>&1
147check4=`root -q -b $macrospath/resetallruns.C+\("\"$filename\""\,"\"$column\""\) | tee $filesondisklogpath/resetall-$column-$datetime.log | intgrep`
148
149case $check4 in
150 1) echo " check4=$check4 -> everything ok -> reset is done" >> $scriptlog 2>&1
151 printprocesslog "INFO rawfiles resetted successfully"
152 ;;
153 0) echo " check1=$check1 -> no connection to db -> continue..." >> $scriptlog 2>&1
154 printprocesslog "WARN connection to DB failed"
155 ;;
156 *) echo " check4=$check4 -> ERROR -> something went wrong while resetting" >> $scriptlog 2>&1
157 printprocesslog "ERROR resettallruns.C failed for rawfiles"
158 ;;
159esac
160
161finish >> $scriptlog 2>&1
162
Note: See TracBrowser for help on using the repository browser.