source: branches/trigger_burst_research/Transfer/RsyncRawToISDC.sh

Last change on this file was 17890, checked in by Daniela Dorner, 10 years ago
do not use function checklock anymore as script is only started when not running
  • Property svn:executable set to *
File size: 5.7 KB
Line 
1#!/bin/bash
2#
3
4source `dirname $0`/../Sourcefile.sh
5printprocesslog "INFO starting $0"
6program=RsyncRawToISDC
7step=RawFileRsyncedISDC
8pwfile=/home_nfs/isdc/fact_opr/rsync.pwd
9
10set -C
11
12logfile=$runlogpath"/RsyncRawToISDC-"$datetime".log"
13date >> $logfile 2>&1
14
15## check if script is already running
16#lockfile=$lockpath/lock-$program.txt
17#checklock
18
19# stop transfer when less than 100 GB are left
20function check_scratch()
21{
22 diskusage2=( `df -P /scratch | grep scratch ` )
23 # check if more than X GB are left on /scratch
24 if [ ${diskusage2[3]} -lt 100000 ]
25 then
26 printprocesslog "DISK less than 100 GB left on /scratch ("${diskusage2[3]}")"
27 #echo "WARN less than 100 GB left on /scratch ("${diskusage2[3]}")"
28 echo "WARN less than 100 GB left on /scratch ("${diskusage2[3]}")" >> $logfile2 2>&1
29 finish
30 fi
31}
32
33check_scratch
34
35# get todo list
36gettodo
37
38for (( s=0 ; s < $num ; s++ ))
39do
40 check_scratch
41 night=${primaries[$s+$s]}
42 runid=${primaries[$s+$s+1]}
43 nightpath=`echo $night | cut -c 1-4`"/"`echo $night | cut -c 5-6`"/"`echo $night | cut -c 7-8`
44 lppath="/loc_data/zipraw/"$nightpath
45 nightrun=$night"_"`printf %03d $runid`
46 lpfile=`ssh fact@161.72.93.131 "find $lppath -type f -regex '.*$nightrun[.]fits[.][fg]z'"`
47 if [ "$lpfile" == "" ]
48 then
49 #echo $nightrun" not yet available on data."
50 printprocesslog "INFO "$nightrun" not yet available on data."
51 continue
52 else
53 filename=`basename $lpfile`
54 fi
55
56 setstatus "start"
57
58 rawfilelp="/loc_data/zipraw/./"$nightpath"/"$filename
59 rawdirisdc="/scratch/from_lapalma/raw/"
60 rawfileisdc=$rawdirisdc$nightpath"/"$filename
61 ingestlinkpath="/scratch/ingest_links/raw/"$nightpath
62 makedir $ingestlinkpath >> $logfile 2>&1
63 ingestlink=$ingestlinkpath"/"$filename
64
65 if ! ssh fact@161.72.93.131 "ls $rawfilelp >/dev/null 2>&1"
66 then
67 #echo $rawfilelp" not yet available on data."
68 printprocesslog "INFO "$rawfilelp" not yet available on data."
69 check="no"
70 setstatus "stop"
71 continue
72 fi
73
74 # for new rsync
75 # remove / from dir
76 # change name of dir (else rsync-server doesn't accept it
77 # test if trick with file/dir is working
78 #echo "INFO rsync rawfile "$rawfilelp" to ISDC "$rawdirisdc
79 printprocesslog "INFO rsync rawfile "$rawfilelp" to ISDC "$rawdirisdc
80 #echo "INFO rsync rawfile "$rawfilelp" to ISDC "$rawdirisdc >> $logfile 2>&1
81 #rsync -rltDvR --partial --stats --password-file=$pwfile factdata@161.72.93.131::$rawfilelp $rawdirisdc >> $logfile 2>&1
82 #echo "rsync -rltDvR -T $rsynctempdir --partial --stats fact@161.72.93.131:$rawfilelp $rawdirisdc >> $logfile 2>&1"
83 rsync -rltDvR -T $rsynctempdir --partial --stats fact@161.72.93.131:$rawfilelp $rawdirisdc >> $logfile 2>&1
84 check1=$?
85
86 case $check1 in
87 0) printprocesslog "INFO rawfile "$rawfilelp" transferred successfully to ISDC."
88 if ! [ -L $ingestlink ]
89 then
90 printprocesslog "INFO create link for "$rawfileisdc
91 ln -sv $rawfileisdc $ingestlink >> $logfile 2>&1
92 check2=$?
93 case $check2 in
94 0) printprocesslog "INFO link for "$rawfileisdc" created successfully."
95 ;;
96 *) printprocesslog "WARN link for "$rawfileisdc" could not be created (check2="$check2")."
97 check=$check2
98 ;;
99 esac
100 else
101 printprocesslog "INFO link "$ingestlink" already existing."
102 fi
103 ;;
104 *) printprocesslog "CONNECTION "$rawfilelp" could not be transferred to ISDC (check1="$check1")."
105 check=$check1
106 ;;
107 esac
108
109 query="SELECT fHasDrsFile from RunInfo WHERE fNight="$night" AND fRunID="$runid
110 numdrs=`sendquery`
111 if [ $numdrs -gt 0 ]
112 then
113 drsfilelp="/loc_data/zipraw/./"$nightpath"/"$nightrun".drs.fits.gz"
114 drsfileisdc=$rawdirisdc$nightpath"/"$nightrun".drs.fits.gz"
115 drsingestlink=$ingestlinkpath"/"$nightrun".drs.fits.gz"
116
117 if ! ssh fact@161.72.93.131 "ls $drsfilelp >/dev/null 2>&1"
118 then
119 #echo $drsfilelp" not yet available on data."
120 printprocesslog "INFO "$drsfilelp" not yet available on data."
121 check="no"
122 setstatus "stop"
123 continue
124 fi
125
126
127 printprocesslog "INFO rsync drsfile "$drsfilelp" to ISDC "$rawdirisdc
128 echo "INFO rsync drsfile "$drsfilelp" to ISDC "$rawdirisdc >> $logfile 2>&1
129 #rsync -rltDvR --partial --stats --password-file=$pwfile factdata@161.72.93.131::$rawfilelp $rawdirisdc >> $logfile 2>&1
130 rsync -rltDvR -T $rsynctempdir --partial --stats fact@161.72.93.131:$drsfilelp $rawdirisdc >> $logfile 2>&1
131 check3=$?
132
133 case $check3 in
134 0) printprocesslog "INFO drsfile "$drsfilelp" transferred successfully to ISDC."
135 if ! [ -L $drsingestlink ]
136 then
137 printprocesslog "INFO create link for "$drsfileisdc
138 ln -sv $drsfileisdc $drsingestlink >> $logfile 2>&1
139 check4=$?
140 case $check4 in
141 0) printprocesslog "INFO link for "$drsfileisdc" created successfully."
142 ;;
143 *) printprocesslog "WARN link for "$drsfileisdc" could not be created (check4="$check4")."
144 check=$check4
145 ;;
146 esac
147 else
148 printprocesslog "INFO link "$drsingestlink" already existing."
149 fi
150 ;;
151 *) printprocesslog "CONNECTION "$drsfilelp" could not be transferred to ISDC (check3="$check3")."
152 check=$check3
153 ;;
154 esac
155 fi
156
157 setstatus "stop"
158done
159
160finish
161
Note: See TracBrowser for help on using the repository browser.