# Why software restart required after timezone database update in Linux?

**URL:** <https://linux-tips.com/t/why-software-restart-required-after-timezone-database-update-in-linux/291>\
**Category:** Programming\
**Created:** [October 27, 2015, 2:29pm UTC](https://linux-tips.com/t/why-software-restart-required-after-timezone-database-update-in-linux/291 "2015-10-27T14:29:32Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![MisterNo](https://linux-tips.com/user_avatar/linux-tips.com/misterno/32/55_2.png) [@MisterNo](https://linux-tips.com/u/MisterNo)\
**Post date:** [October 27, 2015, 2:29pm UTC](https://linux-tips.com/t/why-software-restart-required-after-timezone-database-update-in-linux/291/1 "2015-10-27T14:29:32Z")

</div>

If you have to make updates on timezone database in Linux, already running programs couldn’t detect the changes while newly executed programs display correct information according to new database.

Is there any other way to detect timezone database change on software?

---

<div class="post-metadata">

**Author:** ![demirten](https://linux-tips.com/user_avatar/linux-tips.com/demirten/32/64_2.png) [@demirten](https://linux-tips.com/u/demirten)\
**Post date:** [October 27, 2015, 2:51pm UTC](https://linux-tips.com/t/why-software-restart-required-after-timezone-database-update-in-linux/291/2 "2015-10-27T14:51:38Z")

</div>

This is related with internal behaviour of _glibc_.

Functions about working with timezones can be used very frequently in a software. So, to prevent database file read on every function call that needs timezone info (`localtime`, `gmtime` etc.), timezone database read once and cached when the program started.

If you look at the **strace** output of your program, you’ll see that in the very first steps of strace output (after shared libraries loaded) `/etc/localtime` file was read which includes required information for currently selected timezone:

```auto
$ strace ./myprog
...
brk(0) = 0x1772000
brk(0x1793000) = 0x1793000
open("/etc/localtime", O_RDONLY|O_CLOEXEC) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=2721, ...}) = 0
fstat(3, {st_mode=S_IFREG|0644, st_size=2721, ...}) = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f67c61d3000
read(3, "TZif2\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\t\0\0\0\t\0\"..., 4096) = 2721
lseek(3, -1728, SEEK_CUR) = 993
read(3, "TZif2\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\n\0\0\0\n\0\"..., 4096) = 1728
close(3) = 0
munmap(0x7f67c61d3000, 4096) = 0

```

However, there is a way to detect timezone database update. If you call `tzset()` function, you will see that `/etc/localtime` file was read again and your program displays times according to newly installed database.

If you have the source code of the software, you can make required changes to call `tzset()` function regularly (like once for every day) or provide an interface to trigger calling this function (using custom signals or giving a CLI interface through socket api etc.)

For the services which doesn’t have a method like this, you have to restart it.

See also: [man tzset](http://manpages.org/tzset)
