source: branches/Mars_use_drstimefiles/datacenter/scripts/movingrawfiles_OK@ 20115

Last change on this file since 20115 was 9355, checked in by Daniela Dorner, 16 years ago
*** empty log message ***
File size: 3.5 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
45# check whether script is already running
46lockfile=$lockpath/lock-$program.txt
47checklock
48
49# change permission for files
50ssh tape@dc07 chmod -R g+w /magic/datacenter/fromtape/rawdata/*
51ssh lapalma@dc09 chmod -R g+w /magic/datacenter/fromlapalma/RAW*/
52# output for chmod with -v or -c (only changes)
53
54printprocesslog "INFO moving directories from fromlapalma to fromtape"
55#find directories which have to be copied
56dirs=`ls /magic/datacenter/fromlapalma/RAW/*/*.OK | sed -e 's/.OK//g'`
57if [ ! "$dirs" == "" ]
58then
59 # change permission for this directories
60 ssh lapalma@dc09 chmod -R g+w $dirs
61 # move directories to the tapedirectory
62 dates=`find /magic/datacenter/fromlapalma/RAW/*200* -type d | cut -d/ -f6`
63 for date in ${dates[@]}
64 do
65 ssh lapalma@dc09 mkdir /magic/datacenter/fromlapalma/RAWchk/$date
66 makedir /magic/datacenter/fromtape/rawdata/$date
67
68 OKs=`ls /magic/datacenter/fromlapalma/RAW/$date/*.OK`
69 for OK in ${OKs[@]}
70 do
71 ssh lapalma@dc09 mv -v $OK /magic/datacenter/fromlapalma/RAWchk/$date/
72 files=`echo $OK | sed -e 's/.OK//g'`
73 mv -v $files /magic/datacenter/fromtape/rawdata/$date/
74 done
75 done
76fi
77
78rmdir -v /magic/datacenter/fromlapalma/RAW/*200*
79
80# find rawfiles
81rawfiles=`find /magic/datacenter/fromtape/rawdata/ -name '*.*'`
82
83if [ "$rawfiles" == "" ]
84then
85 printprocesslog "INFO no files to move -> exit"
86 finish
87fi
88
89printprocesslog "INFO moving rawfiles to $datapath/rawfiles"
90for rawfile in $rawfiles
91do
92# workaround for rawfiles with wrong timing
93# newrawfile=`echo $rawfile | sed -e 's/center\/fromtape\/rawdata/\/rawfiles-wrong-timing/g' -e 's/_/\//1' -e 's/_/\//1'`
94 newrawfile=`echo $rawfile | sed -e 's/center\/fromtape\/rawdata/\/rawfiles/g' -e 's/_/\//1' -e 's/_/\//1'`
95 newdir=`dirname $newrawfile`
96 makedir $newdir
97
98 mv -v $rawfile $newrawfile
99done
100
101rmdir -v /magic/datacenter/fromtape/rawdata/*
102
103printprocesslog "INFO launching filesondisk"
104$scriptspath/filesondisk&
105
106finish
107
Note: See TracBrowser for help on using the repository browser.