Forums

Skip to content

Advanced search
  • Quick links
    • Unanswered topics
    • Active topics
    • Search
  • FAQ
  • Login
  • Register
  • Board index Assistance Portage & Programming
  • Search

how exactly to set timezone in /etc/localtime ?[solved]

Problems with emerge or ebuilds? Have a basic programming question about C, PHP, Perl, BASH or something else?
Post Reply
Advanced search
8 posts • Page 1 of 1
Author
Message
padoor
Advocate
Advocate
User avatar
Posts: 4185
Joined: Fri Dec 30, 2005 1:43 am
Location: india

how exactly to set timezone in /etc/localtime ?[solved]

  • Quote

Post by padoor » Tue Jul 24, 2012 3:28 am

Code: Select all

tux ramaswamy # cat /etc/localtime
TZif21Local time zone must be set--see zic manual pageTZif21Local time zone must be set--see zic manual page
<Local time zone must be set--see zic manual page>0
 Asia/Kolkata
tux ramaswamy # man zic
although i get correct time in the hwclock i get the zic message always.
/etc/localtime is as above minus the message
man zic does not say how to set the localtime file.
is there anything to be in front of Asia/kolkata which is my timezone
help needed
Last edited by padoor on Wed Jul 25, 2012 4:43 am, edited 1 time in total.
reach out a little bit more to catch it (DON'T BELIEVE the advocate part under my user name)
Top
khayyam
Watchman
Watchman
User avatar
Posts: 6227
Joined: Thu Jun 07, 2012 2:45 am
Location: Room 101

  • Quote

Post by khayyam » Tue Jul 24, 2012 5:02 am

padoor ...

You probably omitted to copy the timezone data file to /etc during the install ...

Code: Select all

cp /usr/share/zoneinfo/Asia/Kolkata /etc/localtime
best ... khay
Top
padoor
Advocate
Advocate
User avatar
Posts: 4185
Joined: Fri Dec 30, 2005 1:43 am
Location: india

  • Quote

Post by padoor » Wed Jul 25, 2012 4:42 am

copying timezone makes difference in the file than manually entering the time zone.
now the file reads as below.

Code: Select all

TZif2^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^D^@^@^@^D^@^@^@^@^@^@^@^D^@^@^@^D^@^@$
��^���^Eq^X�^�2��t^R^�^A^B^C^B^@^@R�^@^@^@^@[h^@^D^@^@MX^@      ^@^@[h^A       $
^@^@[h^A
LMT^@HMT^@BURT^@IST^@^@^@^@^@^@^@^@^@^@^@
IST-5:30
and the message to set timezone has gone after cp timezone to localtime.
thanks for reply. :D
reach out a little bit more to catch it (DON'T BELIEVE the advocate part under my user name)
Top
Massimo B.
Veteran
Veteran
User avatar
Posts: 1940
Joined: Wed Feb 09, 2005 3:05 pm
Location: PB, Germany

  • Quote

Post by Massimo B. » Tue Nov 05, 2013 7:13 am

khayyam wrote:

Code: Select all

cp /usr/share/zoneinfo/Asia/Kolkata /etc/localtime
btw. why does documentation recommend to copy? Is a symlink also fine? That would better show to me what timezone is actually set without looking into the binary file.
HP ZBook Power G9 i7-12700H,64GB DDR5|HP ProDesk 600 G5 i7-9700,128GB DDR4
Top
666threesixes666
Veteran
Veteran
User avatar
Posts: 1248
Joined: Tue May 31, 2011 9:46 pm
Location: 42.68n 85.41w
Contact:
Contact 666threesixes666
Website

  • Quote

Post by 666threesixes666 » Tue Nov 05, 2013 7:25 am

symlink makes more sense. pro tip, if you're dual booting xp, make xp load utc instead of setting bios to local clock. (see arch wiki) i run a symlink, works good. ive been going over this qutie a bit today.

Code: Select all

mkultra [ ~ ]$ date
Tue Nov  5 02:24:40 EST 2013
mkultra [ ~ ]$ ls -al /etc/localtime 
lrwxrwxrwx 1 root root 27 Nov  4 10:43 /etc/localtime -> /usr/share/zoneinfo/EST5EDT
http://www.funtoo.org/
Top
Fitzcarraldo
Advocate
Advocate
User avatar
Posts: 2057
Joined: Sat Aug 30, 2008 9:49 pm
Location: United Kingdom
Contact:
Contact Fitzcarraldo
Website

  • Quote

Post by Fitzcarraldo » Wed Nov 06, 2013 2:09 am

Apparently it is not always a good idea to make a symlink:
Re: time issue

On Mon, 30 May 2011 10:57:51 +0200, Florian Philipp wrote:

> The localization guide seems to be in a poor state. Copying the zoneinfo
> file from /usr/share... to /etc/localtime is not the best way to do it
> because then you miss updates. It is better to create a symlink between
> the two.

Which will break if /usr is on a separate filesystem.

> Also, instead of setting the timezone in /etc/conf.d/clock, you
> do it in /etc/timezone nowadays (change introduced in baselayout-2 if
> I'm not mistaken).

Setting it in /etc/timezone also takes care of the updates situation,
because the timezone-data ebuild automatically copies the correct file
to /etc/.


--
Neil Bothwick
http://www.gossamer-threads.com/lists/g ... 423#231423
Clevo W230SS: amd64, VIDEO_CARDS="intel modesetting nvidia".
Compal NBLB2: ~amd64, xf86-video-ati. Dual boot Win 7 Pro 64-bit.
OpenRC systemd-utils[udev] elogind KDE on both.

My blog
Top
Massimo B.
Veteran
Veteran
User avatar
Posts: 1940
Joined: Wed Feb 09, 2005 3:05 pm
Location: PB, Germany

  • Quote

Post by Massimo B. » Wed Nov 06, 2013 12:35 pm

Thank you for that information.
Does that mean, setting /etc/timezone makes the ebuild maintain the binary /etc/localtime ? So having /etc/localtime -> /usr/share/zoneinfo/Europe/Berlin will be overwritten by the ebuild anyway?
Ok, breaking with /usr on separate filesystem is a point. I don't have that. So with local /usr having that symlink should be fine with updated /usr/share/zoneinfo/Europe/Berlin as well.
HP ZBook Power G9 i7-12700H,64GB DDR5|HP ProDesk 600 G5 i7-9700,128GB DDR4
Top
Fitzcarraldo
Advocate
Advocate
User avatar
Posts: 2057
Joined: Sat Aug 30, 2008 9:49 pm
Location: United Kingdom
Contact:
Contact Fitzcarraldo
Website

  • Quote

Post by Fitzcarraldo » Wed Nov 06, 2013 2:06 pm

As Neil Bothwick wrote, the sys-libs/timezone-data ebuild takes care of updating /etc/localtime whenever necessary, so symlinking is just not necessary, and copying once only is fine. Have a look at the relevant part of the ebuild and you can see this:

Code: Select all

80 	pkg_config() {
81 	# make sure the /etc/localtime file does not get stale #127899
82 	local tz src etc_lt="${EROOT}etc/localtime"
83 	
84 	if has_version '<sys-apps/baselayout-2' ; then
85 	src="${EROOT}etc/conf.d/clock"
86 	tz=$(unset TIMEZONE ; source "${src}" ; echo ${TIMEZONE-FOOKABLOIE})
87 	else
88 	src="${EROOT}etc/timezone"
89 	if [[ -e ${src} ]] ; then
90 	tz=$(sed -e 's:#.*::' -e 's:[[:space:]]*::g' -e '/^$/d' "${src}")
91 	else
92 	tz="FOOKABLOIE"
93 	fi
94 	fi
95 	[[ -z ${tz} ]] && return 0
96 	
97 	if [[ ${tz} == "FOOKABLOIE" ]] ; then
98 	elog "You do not have TIMEZONE set in ${src}."
99 	
100 	if [[ ! -e ${etc_lt} ]] ; then
101 	# if /etc/localtime is a symlink somewhere, assume they
102 	# know what they're doing and they're managing it themselves
103 	if [[ ! -L ${etc_lt} ]] ; then
104 	cp -f "${EROOT}"/usr/share/zoneinfo/Factory "${etc_lt}"
105 	elog "Setting ${etc_lt} to Factory."
106 	else
107 	elog "Assuming your ${etc_lt} symlink is what you want; skipping update."
108 	fi
109 	else
110 	elog "Skipping auto-update of ${etc_lt}."
111 	fi
112 	return 0
113 	fi
114 	
115 	if [[ ! -e ${EROOT}/usr/share/zoneinfo/${tz} ]] ; then
116 	elog "You have an invalid TIMEZONE setting in ${src}"
117 	elog "Your ${etc_lt} has been reset to Factory; enjoy!"
118 	tz="Factory"
119 	fi
120 	einfo "Updating ${etc_lt} with ${EROOT}usr/share/zoneinfo/${tz}"
121 	[[ -L ${etc_lt} ]] && rm -f "${etc_lt}"
122 	cp -f "${EROOT}"/usr/share/zoneinfo/"${tz}" "${etc_lt}"
123 	}
However, the ebuild is clever enough to skip the automatic update of /etc/localtime if you had already symlinked it.

So, the bottom line is: symlinking brings no additional benefit and won't work anyway for people who have /usr on a separate filesystem. However, for those people who have /usr on the same partition/filesystem, symlinking won't do any harm but is no better than the once-only copying procedure.
Clevo W230SS: amd64, VIDEO_CARDS="intel modesetting nvidia".
Compal NBLB2: ~amd64, xf86-video-ati. Dual boot Win 7 Pro 64-bit.
OpenRC systemd-utils[udev] elogind KDE on both.

My blog
Top
Post Reply

8 posts • Page 1 of 1

Return to “Portage & Programming”

Jump to
  • Assistance
  • ↳   News & Announcements
  • ↳   Frequently Asked Questions
  • ↳   Installing Gentoo
  • ↳   Multimedia
  • ↳   Desktop Environments
  • ↳   Networking & Security
  • ↳   Kernel & Hardware
  • ↳   Portage & Programming
  • ↳   Gamers & Players
  • ↳   Other Things Gentoo
  • ↳   Unsupported Software
  • Discussion & Documentation
  • ↳   Documentation, Tips & Tricks
  • ↳   Gentoo Chat
  • ↳   Gentoo Forums Feedback
  • ↳   Duplicate Threads
  • International Gentoo Users
  • ↳   中文 (Chinese)
  • ↳   Dutch
  • ↳   Finnish
  • ↳   French
  • ↳   Deutsches Forum (German)
  • ↳   Diskussionsforum
  • ↳   Deutsche Dokumentation
  • ↳   Greek
  • ↳   Forum italiano (Italian)
  • ↳   Forum di discussione italiano
  • ↳   Risorse italiane (documentazione e tools)
  • ↳   Polskie forum (Polish)
  • ↳   Instalacja i sprzęt
  • ↳   Polish OTW
  • ↳   Portuguese
  • ↳   Documentação, Ferramentas e Dicas
  • ↳   Russian
  • ↳   Scandinavian
  • ↳   Spanish
  • ↳   Other Languages
  • Architectures & Platforms
  • ↳   Gentoo on ARM
  • ↳   Gentoo on PPC
  • ↳   Gentoo on Sparc
  • ↳   Gentoo on Alternative Architectures
  • ↳   Gentoo on AMD64
  • ↳   Gentoo for Mac OS X (Portage for Mac OS X)
  • Board index
  • All times are UTC
  • Delete cookies

© 2001–2026 Gentoo Foundation, Inc.

Powered by phpBB® Forum Software © phpBB Limited

Privacy Policy

 

 

magic