Skip to content

Instantly share code, notes, and snippets.

@chmouel
Created February 1, 2012 11:30
Show Gist options
  • Save chmouel/1716657 to your computer and use it in GitHub Desktop.
Save chmouel/1716657 to your computer and use it in GitHub Desktop.
change time
#!/bin/bash
set -e
set -x
LOCALTZMD5=$(md5sum /etc/localtime|sed 's/ .*//')
TIMEZONE="Europe/London Europe/Paris America/Chicago America/Los_Angeles"
for tz in ${TIMEZONE};do
[[ -e /usr/share/zoneinfo/${tz} ]] || exit 1
md5=$(md5sum /usr/share/zoneinfo/${tz}|sed 's/ .*//')
[[ ${LOCALTZMD5} == ${md5} ]] && { echo "Current: ${tz}, $(date)" ; break ;}
done
select tz in ${TIMEZONE};do
[[ -e /usr/share/zoneinfo/${tz} ]] || exit 1
sudo cp /usr/share/zoneinfo/${tz} /etc/localtime
echo ${tz}|sudo tee /etc/timezone >/dev/null
break
done
date
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment