| 1 |
#! /usr/bin/env bash |
| 2 |
|
| 3 |
# $Header: /u/gcmpack/mitgcm.org/scripts/check_outp,v 1.17 2009/07/12 16:29:42 jmc Exp $ |
| 4 |
# |
| 5 |
# The purpose of this script is to clean-up (relatively) old monthly |
| 6 |
# collection of testreport results: |
| 7 |
# will replace all experiment sub-dir (in each testreport output dir) |
| 8 |
# with just 1 tar file (it reduces disk-space and number of files/dir |
| 9 |
# by almost 2 order of magnitude). |
| 10 |
# Note: Needs hand editing ! |
| 11 |
|
| 12 |
#- to run from any author machine: |
| 13 |
storeResDir='/net/orwell/export/export-9/mitgcm-testing/results' |
| 14 |
#- to run from orwell (better since it is disk intensive): |
| 15 |
storeResDir='/export/export-9/mitgcm-testing/results' |
| 16 |
|
| 17 |
echo -n "change dir to: " |
| 18 |
cd $storeResDir |
| 19 |
pwd |
| 20 |
|
| 21 |
listM='2006_10' |
| 22 |
#listM=`ls -1 -d 2006_1[1-2] 2007_[0-1][0-9] 2008_[0-1][0-9]` |
| 23 |
listM=`ls -1 -d 2009_0[1-3]` |
| 24 |
echo "listM='$listM'" |
| 25 |
#exit |
| 26 |
|
| 27 |
for MD in $listM |
| 28 |
do |
| 29 |
flag=0 |
| 30 |
echo "===============================================================" |
| 31 |
echo " -- process dir $MD :" |
| 32 |
echo "===============================================================" |
| 33 |
cd $MD |
| 34 |
out=$? |
| 35 |
if test $out != 0 ; then |
| 36 |
echo " cd $MD : error= $out" |
| 37 |
continue |
| 38 |
fi |
| 39 |
tStart=`date` |
| 40 |
listD=`ls -1 -d tr_*` |
| 41 |
#echo $listD |
| 42 |
for dd in $listD |
| 43 |
do |
| 44 |
if test $flag = 1 ; then continue ; fi |
| 45 |
own=-1 |
| 46 |
if test -d $dd ; then |
| 47 |
#echo "> $dd is dir" |
| 48 |
own=`ls -l -d $dd | grep -c $USER` |
| 49 |
fi |
| 50 |
if test $own = 0 ; then |
| 51 |
echo " $USER does not own dir: $dd : ==> skipped" |
| 52 |
fi |
| 53 |
if [ $own -gt 0 ] ; then |
| 54 |
xx=$dd.tar |
| 55 |
if test -f $dd/$xx -o -f $dd/$xx.gz ; then |
| 56 |
echo ' tar file exist:' |
| 57 |
ls -l $dd/${xx}* |
| 58 |
else |
| 59 |
#flag=1 |
| 60 |
echo -n "tar -cf $xx $dd ..." |
| 61 |
tar -cf $xx $dd |
| 62 |
out=$? |
| 63 |
if test $out = 0 ; then |
| 64 |
touch -r $dd/summary.txt $xx |
| 65 |
cd $dd |
| 66 |
nb=0; |
| 67 |
echo -n " ; rm -r [all dir] ..." |
| 68 |
listRM=`ls -1` |
| 69 |
for yy in $listRM |
| 70 |
do |
| 71 |
if test -d $yy ; then |
| 72 |
rm -r $yy |
| 73 |
nb=`expr $nb + 1` |
| 74 |
fi |
| 75 |
done |
| 76 |
cd .. |
| 77 |
echo " (total: $nb) done" |
| 78 |
gzip -9 $xx |
| 79 |
mv $xx.gz $dd |
| 80 |
#ls -l $dd |
| 81 |
else |
| 82 |
echo " : error= $out" |
| 83 |
fi |
| 84 |
fi |
| 85 |
fi |
| 86 |
done |
| 87 |
eStart=`date` |
| 88 |
echo " -- cleaning started at: $tStart" |
| 89 |
echo " ended at: $eStart" |
| 90 |
echo "===============================================================" |
| 91 |
cd .. |
| 92 |
done |
| 93 |
#exit |