source: releases/Mars.2014.05.26/datacenter/scripts/filesondisk@ 18752

Last change on this file since 18752 was 9214, checked in by snruegam, 16 years ago
*** empty log message ***
  • Property svn:executable set to *
File size: 6.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 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
51
52set -C
53
54
55scriptlog=$runlogpath/$program-$datetime.log
56date >> $scriptlog 2>&1
57
58# check if script is already running
59lockfile=$lockpath/lock-$program.txt
60checklock >> $scriptlog 2>&1
61
62filesondisklogpath=$logpath/$program/`date +%Y/%m`
63makedir $filesondisklogpath >> $scriptlog 2>&1
64
65cd $mars
66
67
68# ---------------- check disk for cc-files --------------------
69
70echo "checking disk for ccfiles..." >> $scriptlog 2>&1
71printprocesslog "INFO checking ccfiles"
72filename=$filesondisklogpath/ccfilesondisk-$datetime.txt
73find $subsystempath/cc/ -regextype posix-egrep -regex "^$subsystempath/cc/20[01][0-9]/[01][0-9]/[0-3][0-9]/20[01][0-9][01][0-9][0-3][0-9]_(M[0-9]_)?[0-9]{5,8}(\.[0-9]{3,5})?_[PCDSN]_.*.rep$" | grep -E -o "(_M[0-9])?_[0-9]{5,8}(\.[0-9]{3,5})?_" > $filename
74
75echo "resetting runs..." >> $scriptlog 2>&1
76check3=`root -q -b $macrospath/resetallruns.C+\("\"$filename\""\,"\"fCCFileAvail\"",kFALSE\) | tee -a $scriptlog | 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# ---------------- check disk for caco-files --------------------
92
93echo "checking disk for cacofiles..." >> $scriptlog 2>&1
94printprocesslog "INFO checking cacofiles"
95filename=$filesondisklogpath/cacofilesondisk-$datetime.txt
96
97find $subsystempath/caco/ -regextype posix-egrep -regex "^$subsystempath/caco/20[01][0-9]/[01][0-9]/[0-3][0-9]/dc_20[01][0-9]_[01][0-9]_[0-3][0-9]_[012][0-9]_[0-5][0-9]_[0-5][0-9]_[0-9]{5,8}_.*\.txt$" | grep -E -o "(_M[0-9])?_[0-9]{5,8}(\.[0-9]{3,5})?_" > $filename
98
99echo "resetting runs..." >> $scriptlog 2>&1
100check0=`root -q -b $macrospath/resetallruns.C+\("\"$filename\""\,"\"fCaCoFileAvail\"",kFALSE\) | tee -a $scriptlog | intgrep`
101
102case $check0 in
103 1) echo " check0=$check0 -> everything ok -> reset is done" >> $scriptlog 2>&1
104 printprocesslog "INFO cacofiles resetted successfully"
105 ;;
106 0) echo " check1=$check1 -> no connection to db -> continue..." >> $scriptlog 2>&1
107 printprocesslog "WARN connection to DB failed"
108 ;;
109 *) echo " check0=$check0 -> ERROR -> something went wrong while resetting" >> $scriptlog 2>&1
110 printprocesslog "ERROR resettallruns.C failed for cacofiles"
111 ;;
112esac
113
114
115# ---------------- find missing caco-files --------------------
116
117#echo "finding missing cacofiles..." >> $scriptlog 2>&1
118#printprocesslog "INFO checking missing cacofiles"
119#check1=`root -q -b $macrospath/findcacofiles.C+ | tee -a $scriptlog | intgrep`
120#
121#case $check1 in
122# 1) echo " check1=$check1 -> everything ok -> missing cacofiles are found" >> $scriptlog 2>&1
123# printprocesslog "INFO missing cacofiles found"
124# ;;
125# 0) echo " check1=$check1 -> no connection to db -> continue..." >> $scriptlog 2>&1
126# printprocesslog "WARN connection to DB failed"
127# ;;
128# *) echo " check1=$check1 -> ERROR -> something went wrong while resetting" >> $scriptlog 2>&1
129# printprocesslog "ERROR findcacofiles.C failed"
130# ;;
131#esac
132
133
134# ---------------- check disk for rawfiles --------------------
135
136echo "checking disk for rawfiles..." >> $scriptlog 2>&1
137printprocesslog "INFO checking rawfiles"
138filename=$filesondisklogpath/rawfilesondisk-$datetime.txt
139
140find $datapath/rawfiles/20[01][0-9] -regextype posix-egrep -regex "^$datapath/rawfiles/20[01][0-9]/[01][0-9]/[0-3][0-9]/20[01][0-9][01][0-9][0-3][0-9]_(M[0-9]_)?[0-9]{5,8}(\.[0-9]{3,5})?_[PCDSN]_.*\.raw(\.gz)?$" | grep -E -o "(_M[0-9])?_[0-9]{5,8}(\.[0-9]{3,5})?_" > $filename
141
142echo "resetting runs..." >> $scriptlog 2>&1
143check4=`root -q -b $macrospath/resetallruns.C+\("\"$filename\""\,"\"fRawFileAvail\"",kFALSE\) | tee -a $scriptlog | intgrep`
144
145case $check4 in
146 1) echo " check4=$check4 -> everything ok -> reset is done" >> $scriptlog 2>&1
147 printprocesslog "INFO rawfiles resetted successfully"
148 ;;
149 0) echo " check1=$check1 -> no connection to db -> continue..." >> $scriptlog 2>&1
150 printprocesslog "WARN connection to DB failed"
151 ;;
152 *) echo " check4=$check4 -> ERROR -> something went wrong while resetting" >> $scriptlog 2>&1
153 printprocesslog "ERROR resettallruns.C failed for rawfiles"
154 ;;
155esac
156
157
158
159finish >> $scriptlog 2>&1
Note: See TracBrowser for help on using the repository browser.