source: trunk/DataCheck/Transfer/RsyncAuxLP.sh@ 13389

Last change on this file since 13389 was 13313, checked in by Daniela Dorner, 13 years ago
improved logging
  • Property svn:executable set to *
File size: 2.8 KB
Line 
1#!/bin/bash
2
3# this script has been written to run on La Palma on the machine data
4# i.e. paths are only working on this machine
5
6source `dirname $0`/../Sourcefile.sh
7printprocesslog "INFO starting "$0
8
9logfile=$runlogpath"/RsyncAuxLP-"$datetime".log"
10date >> $logfile
11
12# check if /daq is mounted on data
13if ! mount | grep daq >> $logfile 2>&1
14then
15 printprocesslog "ERROR /daq is not mounted on data => please mount it"
16 echo `date`": /daq is not mounted on data => please mount it"
17 finish
18fi
19
20# check if paths are available
21if ! ls /daq/aux >/dev/null 2>&1
22then
23 printprocesslog "ERROR /daq/aux is not available."
24 finish
25fi
26if ! ls /loc_data/aux >/dev/null 2>&1
27then
28 printprocesslog "ERROR /loc_data/aux is not available."
29 finish
30fi
31
32
33# get last 3 nights
34dates=( `date +%Y/%m/%d --date="-12hour"` `date +%Y/%m/%d --date="-36hour"` `date +%Y/%m/%d --date="-60hour"` )
35
36# do rsync for rawfiles of these dates
37for date in ${dates[@]}
38do
39 echo "" >> $logfile 2>&1
40 # auxiliary data directories on data
41 auxdirdaq=/daq/aux/$date/ # /loc_data from daq via nfs on data
42 if ! [ -d $auxdirdaq ]
43 then
44 auxdirdata=/loc_data/aux/$date/
45 if ! [ -d $auxdirdata ]
46 then
47 printprocesslog "INFO "$auxdirdaq" and "$auxdirdata" not found. " >> $logfile 2>&1
48 else
49 printprocesslog "WARN "$auxdirdaq" not found, but "$auxdirdata". Data were probably taken on data." >> $logfile 2>&1
50 fi
51 echo `date`": "$auxdirdaq" not found. " >> $logfile 2>&1
52 continue
53 fi
54 auxdirdata=/loc_data/aux/$date
55 if ! [ -d $auxdirdata ]
56 then
57 mkdir -pv $auxdirdata >> $logfile 2>&1
58 fi
59 printprocesslog "INFO processing files in "$auxdirdaq >> $logfile 2>&1
60 echo `date`": processing files in "$auxdirdaq >> $logfile 2>&1
61
62 # get current hour
63 hour=`date +%k`
64 # define bwlimit for rsync depending on the time: from 19-7h reduced bwlimit for rsync
65 if [ $hour -le 6 ] || [ $hour -ge 19 ]
66 then
67 # limit bw for rsync to 20 MB/s during night
68 bwlimit="--bwlimit=20000"
69 printprocesslog "INFO rsync data with "$bwlimit >> $logfile 2>&1
70 echo "rsync data with "$bwlimit >> $logfile 2>&1
71 else
72 # no bw limit during day
73 printprocesslog "INFO rsync data without bwlimit" >> $logfile 2>&1
74 echo "rsync data without bwlimit" >> $logfile 2>&1
75 fi
76
77 #rsync from daq to data
78 #if ! /usr/bin/rsync -avxHPu $bwlimit $auxdirdaq $auxdirdata >> $logfile 2>&1 # in case of adding checksum, only update files with rsync
79 if ! /usr/bin/rsync -avxHP -T $rsynctempdir $bwlimit $auxdirdaq $auxdirdata >> $logfile 2>&1
80 then
81 printprocesslog "WARN problem rsyncing auxiliary data for "$date" from daq to data"
82 echo `date`": problem rsyncing auxiliary data for "$date" from daq to data"
83 fi
84done
85
Note: See TracBrowser for help on using the repository browser.