source: trunk/DataCheck/Processing/CheckRawFilesAvail.sh@ 18702

Last change on this file since 18702 was 18699, checked in by Daniela Dorner, 8 years ago
give warning only for last year (to avoid getting warnings for files in fails folder that had been deleted)
  • Property svn:executable set to *
File size: 3.2 KB
Line 
1#!/bin/bash
2#
3
4source `dirname $0`/../Sourcefile.sh
5printprocesslog "INFO starting $0"
6program=CheckRawFilesAvail
7step=RawFileAvailISDC
8transferdelay=3 #days
9failsdir=/archive/fact/fails/raw
10
11set -C
12
13# check if script is already running
14lockfile=$lockpath/lock-$program.txt
15checklock
16
17# get todo list
18gettodo
19
20
21for (( s=0 ; s < $num ; s++ ))
22do
23 night=${primaries[$s+$s]}
24 runid=${primaries[$s+$s+1]}
25 currentnight=`date +%Y%m%d`
26 checknight=`echo " $currentnight - $transferdelay " | bc -l`
27 # work around for 100 missing old files to avoid warnings every hour
28 checknight2=`echo " $currentnight - 365 - $transferdelay " | bc -l`
29
30 setstatus "start"
31
32 night2=`echo $night | cut -c 1-4`/`echo $night | cut -c 5-6`/`echo $night | cut -c 7-8`
33 rawfile=$rawdata/$night2/$night"_"`printf %03d $runid`".fits.fz"
34 failsfile=$failsdir/$night2/$night"_"`printf %03d $runid`".fits.fz"
35
36 test -e $rawfile
37 check1=$?
38
39 query="SELECT fHasDrsFile from RunInfo WHERE fNight="$night" AND fRunID="$runid
40 numdrs=`sendquery`
41 if [ $numdrs -gt 0 ]
42 then
43 drsfile=$rawdata/$night2"/"$night"_"`printf %03d $runid`".drs.fits.gz"
44 failsdrsfile=$failsdir/$night2"/"$night"_"`printf %03d $runid`".drs.fits.gz"
45 test -e $drsfile
46 check3=$?
47 fi
48
49 case $check1 in
50 0) printprocesslog "INFO found rawfile "$rawfile
51 if [ $numdrs -gt 0 ]
52 then
53 case $check3 in
54 0) printprocesslog "INFO found drsfile "$drsfile
55 ;;
56 *) test -e $failsdrsfile
57 check4=$?
58 case $check4 in
59 0) printprocesslog "INFO found rawfile in "$failsdrsfile
60 # drs file is not in archive for files which are ok
61 check=$check4
62 ;;
63 *) # print warning only for files which are older than $transferdelay days
64 if [ $night -lt $checknight ]
65 then
66 printprocesslog "WARN "$drsfile" and "$failsdrsfile" missing."
67 else
68 printprocesslog "INFO "$drsfile" and "$failsdrsfile" missing."
69 fi
70 check="no"
71 ;;
72 esac
73 esac
74 fi
75 ;;
76 *) test -e $failsfile
77 check2=$?
78
79 case $check2 in
80 0) printprocesslog "INFO found rawfile in "$failsfile
81 # raw file is not in archive for files which are ok
82 check=$check2
83 ;;
84 *) # print warning only for files which are older than $transferdelay days and within the last year
85 if [ $night -lt $checknight ] && [ $night -gt $checknight2 ]
86 then
87 printprocesslog "WARN "$rawfile" and "$failsfile" missing."
88 else
89 printprocesslog "INFO "$rawfile" and "$failsfile" missing."
90 fi
91 check="no"
92 ;;
93 esac
94 ;;
95 esac
96
97 setstatus "stop"
98done
99
100finish
101
Note: See TracBrowser for help on using the repository browser.