1 | #!/bin/ksh --login |
---|
2 | # |
---|
3 | # Synchronise the umshared account ancils with Willie's |
---|
4 | # shared directory /nerc/n02/shared/ancil |
---|
5 | # |
---|
6 | # Run from $HOME/temp so the log file goes there. |
---|
7 | # |
---|
8 | #PBS -l select=serial=true:ncpus=1 |
---|
9 | #PBS -l walltime=10:00:00 |
---|
10 | #PBS -A y07 |
---|
11 | #PBS -N sync_ancil |
---|
12 | #PBS -W umask=0022 |
---|
13 | #PBS -j oe |
---|
14 | #PBS -m ae |
---|
15 | #PBS -M w.mcginty@reading.ac.uk |
---|
16 | |
---|
17 | |
---|
18 | NOW=$(date -u) |
---|
19 | |
---|
20 | # Make sure any symbolic links are resolved to absolute path |
---|
21 | export PBS_O_WORKDIR=$(readlink -f $PBS_O_WORKDIR) |
---|
22 | |
---|
23 | # Change to the directory that the job was submitted from |
---|
24 | cd $PBS_O_WORKDIR |
---|
25 | |
---|
26 | #Create a temporary file |
---|
27 | TMPFILE=$(mktemp --tmpdir=$HOME/temp) |
---|
28 | |
---|
29 | time -p rsync -av --stats /nerc/n02/shared/ancil/ \ |
---|
30 | /work/y07/y07/umshared/ancil > $TMPFILE 2>&1 |
---|
31 | RC=$? |
---|
32 | if (( RC != 0 )) |
---|
33 | then |
---|
34 | echo "Rsync to umshared failed." |
---|
35 | echo "return code $RC" |
---|
36 | else |
---|
37 | echo "Rsync to umshared succeeded." |
---|
38 | cat $TMPFILE |
---|
39 | # Summarise the transfer |
---|
40 | ~wmcginty/bin/xfer_rate2 $TMPFILE |
---|
41 | rm $TMPFILE |
---|
42 | fi |
---|
43 | |
---|
44 | NEXT=$(date -u -d "$NOW +7 days" "+%Y%m%d") |
---|
45 | |
---|
46 | qsub -a ${NEXT}1930 $HOME/temp/sync_ancil |
---|
47 | |
---|
48 | #Delete very old log files |
---|
49 | AGE=42 # days |
---|
50 | find $HOME/temp -name "sync_ancil.o*" -mtime +$AGE -exec rm {} \; |
---|
51 | |
---|
52 | return $RC |
---|