1 | #!/bin/bash
|
---|
2 | #
|
---|
3 |
|
---|
4 | source `dirname $0`/../Sourcefile.sh
|
---|
5 | printprocesslog "INFO starting $0"
|
---|
6 | program=RsyncRawToWue
|
---|
7 | step=RawFileAvailWue
|
---|
8 |
|
---|
9 | set -C
|
---|
10 |
|
---|
11 | # checking that not more than $numrsyncwuelimit
|
---|
12 | # instances of the script are running
|
---|
13 | numrsyncwue=`lsof $0 | grep -o -c $0`
|
---|
14 | echo "-"$numrsyncwue"-"
|
---|
15 | if [ $numrsyncwue -gt $numrsyncwuelimit ]
|
---|
16 | then
|
---|
17 | echo "INFO already "$numrsyncwue" BackupRawToWue.sh running -> exit. "
|
---|
18 | finish
|
---|
19 | fi
|
---|
20 |
|
---|
21 | logfile=$runlogpath"/RsyncRawToWue-"$datetime".log"
|
---|
22 | date >> $logfile
|
---|
23 |
|
---|
24 | # get todo list
|
---|
25 | gettodo
|
---|
26 |
|
---|
27 |
|
---|
28 | for (( s=0 ; s < $num ; s++ ))
|
---|
29 | do
|
---|
30 | night=${primaries[$s+$s]}
|
---|
31 | runid=${primaries[$s+$s+1]}
|
---|
32 | nightpath=`echo $night | cut -c 1-4`"/"`echo $night | cut -c 5-6`"/"`echo $night | cut -c 7-8`
|
---|
33 |
|
---|
34 | setstatus "start"
|
---|
35 | if [ $numchanged -eq 0 ]
|
---|
36 | then
|
---|
37 | printprocesslog "INFO "$numchanged" rows were changed in DB => "$night"_"$runid" is already processed => continue."
|
---|
38 | continue
|
---|
39 | fi
|
---|
40 |
|
---|
41 | rawdirisdc="/scratch/from_lapalma/raw"
|
---|
42 | rawfileisdc=$rawdirisdc"/./"$nightpath"/"$night"_"`printf %03d $runid`".fits.gz"
|
---|
43 | rawdirwue="/fact/raw/"
|
---|
44 |
|
---|
45 | printprocesslog "INFO rsync rawfile "$rawfileisdc" to Wue "$rawdirwue
|
---|
46 | #rsync -rltDvR --partial --stats --password-file=/home_nfs/isdc/fact_opr/rsync.pwd factdata@161.72.93.131::$rawfilelp $rawdirisdc >> $logfile 2>&1
|
---|
47 | rsync -avxR --no-p --stats $rawfileisdc operator@coma.astro.uni-wuerzburg.de:$rawdirwue >> $logfile 2>&1
|
---|
48 | check1=$?
|
---|
49 |
|
---|
50 | case $check1 in
|
---|
51 | 0) printprocesslog "INFO rawfile "$rawfileisdc" transferred successfully to Wue."
|
---|
52 | ;;
|
---|
53 | *) printprocesslog "WARN "$rawfileisdc" could not be transferred to Wue."
|
---|
54 | check=$check1
|
---|
55 | ;;
|
---|
56 | esac
|
---|
57 |
|
---|
58 | query="SELECT fHasDrsFile from RunInfo WHERE fNight="$night" AND fRunID="$runid
|
---|
59 | numdrs=`sendquery`
|
---|
60 | if [ $numdrs -gt 0 ]
|
---|
61 | then
|
---|
62 | drsfileisdc=$rawdirisdc"/./"$nightpath"/"$night"_"`printf %03d $runid`".drs.fits.gz"
|
---|
63 | printprocesslog "INFO rsync rawfile "$drsfileisdc" to Wue "$rawdirwue
|
---|
64 | rsync -avxR --no-p --stats $drsfileisdc operator@coma.astro.uni-wuerzburg.de:$rawdirwue >> $logfile 2>&1
|
---|
65 | check1=$?
|
---|
66 |
|
---|
67 | case $check1 in
|
---|
68 | 0) printprocesslog "INFO rawfile "$drsfileisdc" transferred successfully to Wue."
|
---|
69 | ;;
|
---|
70 | *) printprocesslog "WARN "$drsfileisdc" could not be transferred to Wue."
|
---|
71 | check=$check1
|
---|
72 | ;;
|
---|
73 | esac
|
---|
74 | fi
|
---|
75 |
|
---|
76 | setstatus "stop"
|
---|
77 | done
|
---|
78 |
|
---|
79 | finish
|
---|
80 |
|
---|