-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathera5_wrapper.sh.temp
More file actions
executable file
·54 lines (46 loc) · 1.28 KB
/
era5_wrapper.sh.temp
File metadata and controls
executable file
·54 lines (46 loc) · 1.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#!/bin/bash
#
# Wrapper script (called by cron)
#
# Usage: era5_wrapper.sh <priority>
# <priority> must correspond to an existing priority directory
# set some vars
LOCKFILE="/tmp/era5_wrapper.lock"
TSTAMP=$(date -u +%Y%m%dT%H%M%S)
SCRIPTDIR=$(dirname $0)
cd $SCRIPTDIR
ERRORLOG="....../era5/log/era5_wrapper_error.log"
REQUESTDIR="....../era5/Requests/${1}"
COMPLETEDIR="...../era5/Requests/Completed"
echo "--- Starting $0 ($TSTAMP) ---"
# set exclusive lock
echo "Setting lock ..."
LOCKED="NO"
exec 8>$LOCKFILE
#flock -nx 8 || exit 1
flock -nx 8 || LOCKED="YES"
if [ "$LOCKED" == "YES" ] ; then
echo " already locked - exiting!"
exit 1
fi
# set the environment, load required modules
#echo "Loading modules ..."
#module load python3/3.6.2 netcdf
#export LANG=en_AU.utf8
#export LC_ALL=$LANG
# refresh requests
# couple of options: git pull; or rsync ; or nothing
echo "Checking for new requests, priority: $1"
REQUESTS="$(ls $REQUESTDIR/era5_request*.json)"
# loop through list of request files and run the download command
echo "Starting download ..."
for J in $REQUESTS ; do
echo " $J"
era5 scan -f $J 1>/dev/null 2>>$ERRORLOG
echo " Finished , moving request $J"
mv $J ${COMPLETEDIR}/$(basename "$J")
done
# update sqlite db
echo "Updating database ..."
era5 db
echo "--- Done ---"