summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoremkael <emkael@tlen.pl>2017-06-07 14:38:51 +0200
committeremkael <emkael@tlen.pl>2017-06-07 14:38:51 +0200
commit6cb02962bae8e4bf768ef831b877d154f7a1c87f (patch)
tree7c10e6817fd898f0357d9da797791e454b19322a
parent9cce0d58a297b13975f5a61074d514208be9e94c (diff)
Crontab configuration for fetching Cezar DB
-rw-r--r--_cron/cezar-db1
-rwxr-xr-xbin/fetch-cezar-db.sh9
2 files changed, 6 insertions, 4 deletions
diff --git a/_cron/cezar-db b/_cron/cezar-db
new file mode 100644
index 0000000..ffa3271
--- /dev/null
+++ b/_cron/cezar-db
@@ -0,0 +1 @@
+0 1 1 1,4,7,10 * $SITEPATH/bin/fetch-cezar-db.sh
diff --git a/bin/fetch-cezar-db.sh b/bin/fetch-cezar-db.sh
index 839e07c..3af7357 100755
--- a/bin/fetch-cezar-db.sh
+++ b/bin/fetch-cezar-db.sh
@@ -2,11 +2,12 @@
PAGEDIR=`dirname $0`
DATE=`date --date='yesterday' +%Y%m%d`
OUTPUTFILE=`realpath $PAGEDIR/../data/cezar/$DATE.csv`
-wget http://msc.com.pl/cezar/download/baza.csv -q -O - | iconv -f windows-1250 -t utf-8 > temp
-if [ -s temp ]; then
- tail -n +2 temp | sort > $OUTPUTFILE
+TMPFILE=$PAGEDIR/temp
+wget http://msc.com.pl/cezar/download/baza.csv -q -O - | iconv -f windows-1250 -t utf-8 > $TMPFILE
+if [ -s $TMPFILE ]; then
+ tail -n +2 $TMPFILE | sort > $OUTPUTFILE
echo "Downloaded Cezar CSV into $OUTPUTFILE"
else
echo 'Cezar CSV fetch failed'
fi
-rm temp
+rm $TMPFILE