Skip to content

Instantly share code, notes, and snippets.

@avanavana
Last active March 26, 2021 12:51
Show Gist options
  • Save avanavana/0c6aa71c5c9a6c69d2e88ba4b6b6d084 to your computer and use it in GitHub Desktop.
Save avanavana/0c6aa71c5c9a6c69d2e88ba4b6b6d084 to your computer and use it in GitHub Desktop.
Checks timezonedb.com to see if timezone sql and csv db files have been updated today, and downloads them both if they have. Meant to be run daily with crontab.
#!/bin/bash
# add to crontab with something like '* 0 * * * /path/to/tzdb.sh &>/dev/null'
# change the -o option's parameter to save the files in a different dir on your machine
date=`date "+%Y-%m-%d"`
if [[ ! `curl -s https://timezonedb.com/date.txt` < "$date" ]]; then
curl -s "https://timezonedb.com/files/timezonedb.{csv,sql}.zip" -o "tzdb-${date}-#1.zip"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment