source: trunk/DataCheck/Transfer/RsyncRawToISDC.sh@ 17033

Last change on this file since 17033 was 13342, checked in by Daniela Dorner, 13 years ago
improved logging
  • Property svn:executable set to *
File size: 4.0 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
16lockfile=$lockpath/lock-$program.txt
17checklock
18
19# get todo list
20gettodo
21
22for (( s=0 ; s < $num ; s++ ))
23do
24 night=${primaries[$s+$s]}
25 runid=${primaries[$s+$s+1]}
26 nightpath=`echo $night | cut -c 1-4`"/"`echo $night | cut -c 5-6`"/"`echo $night | cut -c 7-8`
27
28 setstatus "start"
29
30 rawfilelp="/loc_data/zipraw/./"$nightpath"/"$night"_"`printf %03d $runid`".fits.gz"
31 rawdirisdc="/scratch/from_lapalma/raw/"
32 rawfileisdc=$rawdirisdc$nightpath"/"$night"_"`printf %03d $runid`".fits.gz"
33 ingestlinkpath="/scratch/ingest_links/raw/"$nightpath
34 makedir $ingestlinkpath >> $logfile 2>&1
35 ingestlink=$ingestlinkpath"/"$night"_"`printf %03d $runid`".fits.gz"
36
37 printprocesslog "INFO rsync rawfile "$rawfilelp" to ISDC "$rawdirisdc
38 echo "INFO rsync rawfile "$rawfilelp" to ISDC "$rawdirisdc >> $logfile 2>&1
39 #rsync -rltDvR --partial --stats --password-file=$pwfile factdata@161.72.93.131::$rawfilelp $rawdirisdc >> $logfile 2>&1
40 rsync -rltDvR -T $rsynctempdir --partial --stats fact@161.72.93.131:$rawfilelp $rawdirisdc >> $logfile 2>&1
41 check1=$?
42
43 case $check1 in
44 0) printprocesslog "INFO rawfile "$rawfilelp" transferred successfully to ISDC."
45 if ! [ -L $ingestlink ]
46 then
47 printprocesslog "INFO create link for "$rawfileisdc
48 ln -sv $rawfileisdc $ingestlink >> $logfile 2>&1
49 check2=$?
50 case $check2 in
51 0) printprocesslog "INFO link for "$rawfileisdc" created successfully."
52 ;;
53 *) printprocesslog "WARN link for "$rawfileisdc" could not be created (check2="$check2")."
54 check=$check2
55 ;;
56 esac
57 else
58 printprocesslog "INFO link "$ingestlink" already existing."
59 fi
60 ;;
61 *) printprocesslog "WARN "$rawfilelp" could not be transferred to ISDC (check1="$check1")."
62 check=$check1
63 ;;
64 esac
65
66 query="SELECT fHasDrsFile from RunInfo WHERE fNight="$night" AND fRunID="$runid
67 numdrs=`sendquery`
68 if [ $numdrs -gt 0 ]
69 then
70 drsfilelp="/loc_data/zipraw/./"$nightpath"/"$night"_"`printf %03d $runid`".drs.fits.gz"
71 drsfileisdc=$rawdirisdc$nightpath"/"$night"_"`printf %03d $runid`".drs.fits.gz"
72 drsingestlink=$ingestlinkpath"/"$night"_"`printf %03d $runid`".drs.fits.gz"
73 printprocesslog "INFO rsync drsfile "$drsfilelp" to ISDC "$rawdirisdc
74 echo "INFO rsync drsfile "$drsfilelp" to ISDC "$rawdirisdc >> $logfile 2>&1
75 #rsync -rltDvR --partial --stats --password-file=$pwfile factdata@161.72.93.131::$rawfilelp $rawdirisdc >> $logfile 2>&1
76 rsync -rltDvR -T $rsynctempdir --partial --stats fact@161.72.93.131:$drsfilelp $rawdirisdc >> $logfile 2>&1
77 check3=$?
78
79 case $check3 in
80 0) printprocesslog "INFO drsfile "$drsfilelp" transferred successfully to ISDC."
81 if ! [ -L $drsingestlink ]
82 then
83 printprocesslog "INFO create link for "$drsfileisdc
84 ln -sv $drsfileisdc $drsingestlink >> $logfile 2>&1
85 check4=$?
86 case $check4 in
87 0) printprocesslog "INFO link for "$drsfileisdc" created successfully."
88 ;;
89 *) printprocesslog "WARN link for "$drsfileisdc" could not be created (check4="$check4")."
90 check=$check4
91 ;;
92 esac
93 else
94 printprocesslog "INFO link "$drsingestlink" already existing."
95 fi
96 ;;
97 *) printprocesslog "WARN "$drsfilelp" could not be transferred to ISDC (check3="$check3")."
98 check=$check3
99 ;;
100 esac
101 fi
102
103 setstatus "stop"
104done
105
106finish
107
Note: See TracBrowser for help on using the repository browser.