source: trunk/MagicSoft/Mars/datacenter/scripts/movingrawfiles_OK@ 8682

Last change on this file since 8682 was 8682, checked in by snruegam, 17 years ago
*** empty log message ***
File size: 3.8 KB
Line 
1#!/bin/sh
2#
3# ========================================================================
4#
5# *
6# * This file is part of MARS, the MAGIC Analysis and Reconstruction
7# * Software. It is distributed to you in the hope that it can be a useful
8# * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
9# * It is distributed WITHOUT ANY WARRANTY.
10# *
11# * Permission to use, copy, modify and distribute this software and its
12# * documentation for any purpose is hereby granted without fee,
13# * provided that the above copyright notice appear in all copies and
14# * that both that copyright notice and this permission notice appear
15# * in supporting documentation. It is provided "as is" without express
16# * or implied warranty.
17# *
18#
19#
20# Author(s): Daniela Dorner 08/2004 <mailto:dorner@astro.uni-wuerzburg.de>
21# Author(s): Stefan Ruegamer 02/2007 <mailto:snruegam@astro.uni-wuerzburg.de>
22#
23# Copyright: MAGIC Software Development, 2000-2007
24#
25#
26# ========================================================================
27#
28# This script is moving the rawfiles from the directory
29# /magic/datacenter/fromtape/rawdata to the structure
30# /magic/data/rawfiles/YYYY/MM/DD
31#
32# Before running this script via cronjob, a check has to be included
33# which logs in to La Palma and checks if the corresponding link in the
34# Wuerbzurg transfer folder has already been deleted (else the file will
35# be transferred again after moving)
36#
37
38source `dirname $0`/sourcefile
39printprocesslog "INFO starting $0"
40program=movingrawfiles_OK
41
42set -C
43umask 0002
44
45scriptlog=$runlogpath/$program-$datetime.log
46date >> $scriptlog 2>&1
47
48# check whether script is already running
49lockfile=$lockpath/lock-$program.txt
50checklock >> $scriptlog 2>&1
51
52# change permission for files
53ssh tape@dc07 chmod -R g+w /magic/datacenter/fromtape/rawdata/* >> $scriptlog 2>&1
54ssh lapalma@dc09 chmod -R g+w /magic/datacenter/fromlapalma/RAW*/ >> $scriptlog 2>&1
55# output for chmod with -v or -c (only changes)
56
57printprocesslog "INFO moving directories from fromlapalma to fromtape"
58#find directories which have to be copied
59dirs=`ls /magic/datacenter/fromlapalma/RAW/*/*.OK | sed -e 's/.OK//g'`
60if [ ! "$dirs" == "" ]
61then
62 # change permission for this directories
63 ssh lapalma@dc09 chmod -R g+w $dirs >> $scriptlog 2>&1
64 # move directories to the tapedirectory
65 dates=`find /magic/datacenter/fromlapalma/RAW/*200* -type d | cut -d/ -f6`
66 for date in ${dates[@]}
67 do
68 ssh lapalma@dc09 mkdir /magic/datacenter/fromlapalma/RAWchk/$date >> $scriptlog 2>&1
69 makedir /magic/datacenter/fromtape/rawdata/$date >> $scriptlog 2>&1
70
71 OKs=`ls /magic/datacenter/fromlapalma/RAW/$date/*.OK`
72 for OK in ${OKs[@]}
73 do
74 ssh lapalma@dc09 mv -v $OK /magic/datacenter/fromlapalma/RAWchk/$date/ >> $scriptlog 2>&1
75 files=`echo $OK | sed -e 's/.OK//g'`
76 mv -v $files /magic/datacenter/fromtape/rawdata/$date/ >> $scriptlog 2>&1
77 done
78 done
79fi
80
81rmdir -vp /magic/datacenter/fromlapalma/RAW/*200* >> $scriptlog 2>&1
82
83# find rawfiles
84rawfiles=`find /magic/datacenter/fromtape/rawdata/ -name '*.*'`
85
86if [ "$rawfiles" == "" ]
87then
88 echo "no files to move -> exit" >> $scriptlog 2>&1
89 finish >> $scriptlog 2>&1
90fi
91
92printprocesslog "INFO moving rawfiles to $datapath/rawfiles"
93for rawfile in $rawfiles
94do
95# workaround for rawfiles with wrong timing
96# newrawfile=`echo $rawfile | sed -e 's/center\/fromtape\/rawdata/\/rawfiles-wrong-timing/g' -e 's/_/\//1' -e 's/_/\//1'`
97 newrawfile=`echo $rawfile | sed -e 's/center\/fromtape\/rawdata/\/rawfiles/g' -e 's/_/\//1' -e 's/_/\//1'`
98 newdir=`dirname $newrawfile`
99 makedir $newdir >> $scriptlog 2>&1
100
101 mv -v $rawfile $newrawfile >> $scriptlog 2>&1
102done
103
104rmdir -v /magic/datacenter/fromtape/rawdata/* >> $scriptlog 2>&1
105
106printprocesslog "INFO launching filesondisk"
107echo "launching filesondisk" >> $scriptlog 2>&1
108$scriptspath/filesondisk&
109
110finish >> $scriptlog 2>&1
111
Note: See TracBrowser for help on using the repository browser.