Set environment variable globally

J Fernyhough j.fernyhough at gmail.com
Wed Apr 5 19:01:26 UTC 2017


On 24/03/17 21:19, Andrew Martin wrote:
> Hello,
> 
> I recently saw this blog post regarding performance when the TZ environment
> variable is not set:
> https://blog.packagecloud.io/eng/2017/02/21/set-environment-variable-save-thousands-of-system-calls/
> 

There's also a good deal of discussion on the HN thread:
https://news.ycombinator.com/item?id=13697555

> I tried defining TZ in /etc/environment and in /etc/profile.d/test.sh, but I
> cannot get this environment variable to be available in all cases (e.g. if I
> just execute bash without --login or if I run the sample c program provided in
> the above article). How can I make the TZ environment variable defined
> completely system-wide?

Before you go too far with that, is there a specific reason you want to
do this? For example, there's not generally a lot of advantage unless
you have a process that does a lot of timezone-based processing.

However, all you should need in /etc/environment is:

TZ=:/etc/localtime

or an equivalent TZ value, e.g.:

TZ=:Europe/London


J


-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 866 bytes
Desc: OpenPGP digital signature
URL: <https://lists.ubuntu.com/archives/ubuntu-devel-discuss/attachments/20170405/dbe9b917/attachment.sig>


More information about the Ubuntu-devel-discuss mailing list