1 |
ccflib |
1.1 |
#! /bin/bash |
2 |
|
|
# |
3 |
|
|
# cif_manager |
4 |
|
|
# |
5 |
|
|
# This script does the following operations in sequence: |
6 |
|
|
# 1) Gets the latest cif files created in the ftp-area/download subdirectory of ccflib |
7 |
|
|
# on xvsoc01 by the cifbuild on-line tool included in the calibration section of web page |
8 |
|
|
# 2) Registers any new *xmm-newton.cif files in the DELIVERY_LOG |
9 |
|
|
# 3) Runs on xvsoc01 the scripts clean_cif_files and clean_uploaded_files |
10 |
|
|
# to remove any *xmm-newton.cif and *uploaded.cif files older than 24 hrs |
11 |
|
|
# 4) Cleans up the local ftp-area/download directory of any *.cif files older than 24 hrs. |
12 |
|
|
# |
13 |
|
|
# This script is run 15 min after the hour for all hours of day by cron. |
14 |
|
|
# |
15 |
ccflib |
1.2 |
# $Id: cif_manager,v 1.1 2015/03/06 15:38:56 ccflib Exp $ |
16 |
ccflib |
1.1 |
|
17 |
|
|
|
18 |
|
|
# 1) Synchronizes both directories |
19 |
|
|
|
20 |
|
|
rsync -a -e ssh ccflib@xmm.esac.esa.int:/data/xmm/ftp/pub/ccf/download/ \ |
21 |
|
|
/home/ccflib/ftp-area/download/ |
22 |
|
|
|
23 |
|
|
|
24 |
|
|
# 2) Registers any new file in DELIVERY_LOG |
25 |
|
|
|
26 |
ccflib |
1.2 |
for file in `ls -1tr /home/ccflib/ftp-area/download/*xmm-newton.cif` |
27 |
ccflib |
1.1 |
do |
28 |
ccflib |
1.2 |
file=`basename $file` |
29 |
|
|
registered=`grep -c "$file" /home/ccflib/ftp-area/download/DELIVERY_LOG` |
30 |
ccflib |
1.1 |
[ "$registered" = "1" ] && continue |
31 |
|
|
mtime=`stat --printf=%y $file | awk -F"." '{print $1}'` |
32 |
|
|
printf "%-40s %-10s %-10s\n" $file $mtime |
33 |
|
|
done >> /home/ccflib/ftp-area/download/DELIVERY_LOG |
34 |
|
|
|
35 |
|
|
# 3) Runs on xvsoc01 through ssh the clean_cif_files and clean_uploaded_files scripts |
36 |
|
|
|
37 |
|
|
ssh ccflib@xmm.esac.esa.int "/data/xmm/ccflib/bin/clean_cif_files" |
38 |
|
|
ssh ccflib@xmm.esac.esa.int "/data/xmm/ccflib/bin/clean_uploaded_files" |
39 |
|
|
|
40 |
|
|
# 4) Cleans up any *.cif files older than 24hrs |
41 |
|
|
|
42 |
|
|
find /home/ccflib/ftp-area/download/ -type f -name "*.cif" -mtime +1 -exec rm {} \; |
43 |
|
|
|