Docs/MirroringStdAncilFiles: do_xfer2

File do_xfer2, 1.4 KB (added by willie, 4 months ago)

Cron job to transfer ancils from Exeter to RDF

Line 
1#!/bin/bash
2#
3# W. McGinty
4# 20 Mar 2018
5#
6# Run the transfer on the Exeter computer so that I don't have to walk down
7# the corridor to check rld042 every week.
8#
9# To be run by a cron job on an Met Office Exeter computer e.g. els040
10#
11# Use UTC for time - 27th Mar 2018
12#
13set -u
14
15# Access SSH agent
16SSH_ENV=$HOME/.ssh/environment.$(hostname)
17. $SSH_ENV > /dev/null 2>&1
18
19
20LOG_FILE=$HOME/ancil_sync_logs/$(date -u +%F_%T).log
21SUMMARY=$HOME/Documents/Ancil_Sync_Summary.csv
22
23MY_EMAIL=william.mcginty@ncas.ac.uk
24
25# Construct the email message in a temporary file
26MSG_FILE=$(mktemp --tmpdir=$HOME/temp)
27
28echo "Running on $(hostname)" >> $LOG_FILE
29echo "Computer status: $(uptime)" >> $LOG_FILE
30#
31# Run the mirror program and time it.
32TIME_LOG=$(mktemp --tmpdir=$HOME/temp) # temp file for the time
33/usr/bin/time -o $TIME_LOG -p  $HOME/bin/mirror_anc_archer \
34           2>> $MSG_FILE 1>> $LOG_FILE
35RC=$?
36
37echo -n "$(hostname),$(date +%F), $(date -u +%T),  $RC, " >>$MSG_FILE
38
39# Get the duration in seconds
40Durn=$(grep real $TIME_LOG | awk '{ print $2 }')
41
42$HOME/bin/xfer_rate $LOG_FILE $Durn 2>&1 >>  $MSG_FILE
43
44cat $MSG_FILE >> $LOG_FILE
45
46# Mail me when done.
47cat $MSG_FILE | mailx -s "Met Office Ancil synch to ARCHER RDF" \
48                      -r $MY_EMAIL $MY_EMAIL
49
50cat $MSG_FILE >> $SUMMARY
51
52# Send the updated summary to PUMA
53rsync -a $SUMMARY willie@puma.nerc.ac.uk:/home/willie/temp
54
55
56rm -rf $MSG_FILE $TIME_LOG