source: trunk/DataCheck/ZipRawData.sh@ 12551

Last change on this file since 12551 was 12547, checked in by Daniela Dorner, 13 years ago
added (script to zip raw data on data)
  • Property svn:executable set to *
File size: 1.3 KB
Line 
1#!/bin/bash
2
3year=`date +%Y --date="-1day"`
4month=`date +%m --date="-1day"`
5
6today=`date +%F`
7logfile=/home/`whoami`/DataCheck/log/ZipRaw$today.log
8
9rawdir=/loc_data/raw/$year/$month
10echo `date`": processing files in "$rawdir >> $logfile
11
12#find all directories in $rawdir
13dirs=`find $rawdir -type d | sort`
14
15echo `date`": create missing directories in /loc_data/zipraw/$year/$month" >> $logfile
16for dir in $dirs
17do
18 zipdir=`echo $dir | sed -e 's/raw/zipraw/'`
19 # check if output directory for zip already exists
20 if [ -d $zipdir ]
21 then
22 continue
23 fi
24 # create output directory for zip
25 mkdir -pv $zipdir >> $logfile
26done
27
28echo `date`": finding files to be zipped in $rawdir..." >> $logfile
29fitsfiles=`find $rawdir -type f -name '*fits' | sort -r`
30
31echo `date`": zipping files in $rawdir..." >> $logfile
32for file in $fitsfiles
33do
34 zipfile=`echo $file | sed -e 's/raw/zipraw/' -e 's/fits/fits.gz/'`
35 zipfiletmp=`echo $file | sed -e 's/raw/zipraw/' -e 's/fits/fits.tmp.gz/'`
36 # check if zipped file already exists
37 if [ -e $zipfile ]
38 then
39 continue
40 fi
41 echo `date`": zipping "$file" to "$zipfile" ..." >> $logfile
42 # zip file to stdout and pipe it to outputfile
43 if pigz -1 -c -f $file > $zipfiletmp;
44 then
45 mv -v $zipfiletmp $zipfile >> $logfile
46 else
47 rm -v $zipfiletmp >> $logfile
48 fi
49done
Note: See TracBrowser for help on using the repository browser.