source: trunk/DataCheck/Transfer/BackupRawToWue.sh@ 16542

Last change on this file since 16542 was 15596, checked in by Daniela Dorner, 12 years ago
allow more than one instance of script and moved control of number of instances from cron to script
  • Property svn:executable set to *
File size: 2.4 KB
Line 
1#!/bin/bash
2#
3
4source `dirname $0`/../Sourcefile.sh
5printprocesslog "INFO starting $0"
6program=RsyncRawToWue
7step=RawFileAvailWue
8
9set -C
10
11# checking that not more than $numrsyncwuelimit
12# instances of the script are running
13numrsyncwue=`lsof $0 | grep -o -c $0`
14echo "-"$numrsyncwue"-"
15if [ $numrsyncwue -gt $numrsyncwuelimit ]
16then
17 echo "INFO already "$numrsyncwue" BackupRawToWue.sh running -> exit. "
18 finish
19fi
20
21logfile=$runlogpath"/RsyncRawToWue-"$datetime".log"
22date >> $logfile
23
24# get todo list
25gettodo
26
27
28for (( s=0 ; s < $num ; s++ ))
29do
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"
77done
78
79finish
80
Note: See TracBrowser for help on using the repository browser.