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 09/2006 <mailto:dorner@astro.uni-wuerzburg.de>
|
---|
21 | #
|
---|
22 | # Copyright: MAGIC Software Development, 2000-2006
|
---|
23 | #
|
---|
24 | #
|
---|
25 | # ========================================================================
|
---|
26 | #
|
---|
27 | # This script zips the incoming rawfiles.
|
---|
28 | #
|
---|
29 |
|
---|
30 | source `dirname $0`/sourcefile
|
---|
31 | printprocesslog "INFO starting $0"
|
---|
32 | program=zipscript
|
---|
33 |
|
---|
34 | set -C
|
---|
35 |
|
---|
36 | rawdatapath=$datapath/rawfiles
|
---|
37 | files=`find $rawdatapath -type f -name '*.raw'`
|
---|
38 |
|
---|
39 | scriptlog=$runlogpath/$program-$datetime.log
|
---|
40 | date >> $scriptlog 2>&1
|
---|
41 |
|
---|
42 | # check if script is already running
|
---|
43 | lockfile=$lockpath/lock-$program.txt
|
---|
44 | checklock >> $scriptlog 2>&1
|
---|
45 |
|
---|
46 |
|
---|
47 | if [ "$files" == "" ]
|
---|
48 | then
|
---|
49 | echo "no files to zip" >> $scriptlog 2>&1
|
---|
50 | finish >> $scriptlog 2>&1
|
---|
51 | fi
|
---|
52 |
|
---|
53 | for file in ${files[@]}
|
---|
54 | do
|
---|
55 | echo "zipping $file ..." >> $scriptlog 2>&1
|
---|
56 | # if ssh pegasus nice -n 19 gzip -1f $file >> $scriptlog 2>&1
|
---|
57 | if ssh phoenix nice -n 19 gzip -1f $file >> $scriptlog 2>&1
|
---|
58 |
|
---|
59 | then
|
---|
60 | chmod a-w $file >> $scriptlog 2>&1
|
---|
61 | fi
|
---|
62 | done
|
---|
63 |
|
---|
64 | finish >> $scriptlog 2>&1
|
---|
65 |
|
---|
66 |
|
---|
67 |
|
---|
68 | # old code for running script locally
|
---|
69 |
|
---|
70 | #rawdatapath=$datapath/rawfiles
|
---|
71 | ##h: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
|
---|
72 | #pnos=( 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 )
|
---|
73 | #sl1=30 #sleeping time before new directory
|
---|
74 | #sl2=60 #sleeping time before new process check
|
---|
75 | #
|
---|
76 | #dirs=`find $rawdatapath -type d | grep -v timecorrlogs | sort`
|
---|
77 | ##dirs=`find $rawdatapath -type d | grep -v timecorrlogs | sort -r`
|
---|
78 | #
|
---|
79 | #for dir in ${dirs[@]}
|
---|
80 | #do
|
---|
81 | # cont=`echo $dir | cut -d/ -f7`
|
---|
82 | # if [ "$cont" == "" ]
|
---|
83 | # then
|
---|
84 | # continue
|
---|
85 | # fi
|
---|
86 | #
|
---|
87 | # if ! ls $dir/*.raw >/dev/null 2>&1
|
---|
88 | # then
|
---|
89 | # echo "no unzipped rawfiles in $dir left"
|
---|
90 | # continue
|
---|
91 | # fi
|
---|
92 | #
|
---|
93 | # echo "sleeping $sl1..."
|
---|
94 | # sleep $sl1
|
---|
95 | #
|
---|
96 | # h=`date +%k`
|
---|
97 | # count=`ps aux | grep gzip | grep -v grep | wc -l`
|
---|
98 | # echo "count: $count - h: $h - pno: ${pnos[$h]}"
|
---|
99 | # while [ "$count" -ge "${pnos[$h]}" ]
|
---|
100 | # do
|
---|
101 | # echo "sleeping $sl2..."
|
---|
102 | # sleep $sl2
|
---|
103 | # h=`date +%k`
|
---|
104 | # count=`ps aux | grep gzip | grep -v grep | wc -l`
|
---|
105 | # echo "count: $count - h: $h - pno: ${pnos[$h]}"
|
---|
106 | # done
|
---|
107 | # echo $dir
|
---|
108 | # du -hs $dir
|
---|
109 | # echo "gzip -1f $dir/*.raw &"
|
---|
110 | # gzip -1f $dir/*.raw &
|
---|
111 | #done
|
---|
112 | #
|
---|
113 |
|
---|
114 |
|
---|
115 | # old code for running script with condor
|
---|
116 |
|
---|
117 | #rawdatapath=$datapath/rawfiles
|
---|
118 | ##h: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
|
---|
119 | #pnos=( 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 )
|
---|
120 | #sl1=30 #sleeping time before new directory
|
---|
121 | #sl2=60 #sleeping time before new process check
|
---|
122 | #
|
---|
123 | #dirs=`find $rawdatapath -type d | grep -v timecorrlogs | sort`
|
---|
124 | ##dirs=`find $rawdatapath -type d | grep -v timecorrlogs | sort -r`
|
---|
125 | #
|
---|
126 | #for dir in ${dirs[@]}
|
---|
127 | #do
|
---|
128 | # cont=`echo $dir | cut -d/ -f7`
|
---|
129 | # if [ "$cont" == "" ]
|
---|
130 | # then
|
---|
131 | # continue
|
---|
132 | # fi
|
---|
133 | #
|
---|
134 | # if ! ls $dir/*.raw >/dev/null 2>&1
|
---|
135 | # then
|
---|
136 | # echo "no unzipped rawfiles in $dir left"
|
---|
137 | # continue
|
---|
138 | # fi
|
---|
139 | #
|
---|
140 | # echo "sleeping $sl1..."
|
---|
141 | # sleep $sl1
|
---|
142 | #
|
---|
143 | # h=`date +%k`
|
---|
144 | # count=`grep gzip .condor_run.* | wc -l`
|
---|
145 | # echo "count: $count - h: $h - pno: ${pnos[$h]}"
|
---|
146 | # while [ "$count" -ge "${pnos[$h]}" ]
|
---|
147 | # do
|
---|
148 | # echo "sleeping $sl2..."
|
---|
149 | # sleep $sl2
|
---|
150 | # h=`date +%k`
|
---|
151 | # count=`grep gzip .condor_run.* | wc -l`
|
---|
152 | # echo "count: $count - h: $h - pno: ${pnos[$h]}"
|
---|
153 | # done
|
---|
154 | # echo $dir
|
---|
155 | # du -hs $dir
|
---|
156 | # condor_run gzip -1f $dir/*.raw &
|
---|
157 | #
|
---|
158 | #done
|
---|
159 | #
|
---|
160 |
|
---|