Why software restart required after timezone database update in Linux?

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?

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:

$ 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