1 | #!/bin/bash
|
---|
2 | #
|
---|
3 |
|
---|
4 | source `dirname $0`/../Sourcefile.sh
|
---|
5 | printprocesslog "INFO starting $0"
|
---|
6 | program=CheckRawFilesAvail
|
---|
7 | step=RawFileAvailISDC
|
---|
8 | transferdelay=3 #days
|
---|
9 | failsdir=/archive/fact/fails/raw
|
---|
10 |
|
---|
11 | set -C
|
---|
12 |
|
---|
13 | # check if script is already running
|
---|
14 | lockfile=$lockpath/lock-$program.txt
|
---|
15 | checklock
|
---|
16 |
|
---|
17 | # get todo list
|
---|
18 | gettodo
|
---|
19 |
|
---|
20 |
|
---|
21 | for (( s=0 ; s < $num ; s++ ))
|
---|
22 | do
|
---|
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"
|
---|
98 | done
|
---|
99 |
|
---|
100 | finish
|
---|
101 |
|
---|