From 6cb02962bae8e4bf768ef831b877d154f7a1c87f Mon Sep 17 00:00:00 2001 From: emkael Date: Wed, 7 Jun 2017 14:38:51 +0200 Subject: Crontab configuration for fetching Cezar DB --- bin/fetch-cezar-db.sh | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'bin') 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 -- cgit v1.2.3