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/
I have noticed this problem when stracing running daemons on my systems and would like to fix it. I reviewed the official Ubuntu documentation for where to define environment variables: https://help.ubuntu.com/community/EnvironmentVariables
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?
Edit: It was suggested that my question is a duplicate of this other post, but the methods described in that post do not solve this problem. I tried both of these:
sudo dpkg-reconfigure tzdata and
sudo timedatectl set-timezone America/New_York. After, I confirmed that /etc/localtime is a valid symlink as expected. However, after a reboot I still see 10 stat() calls to /etc/localtime as documented in the original article I posted above. The behavior I am looking for (as documented in the original article) is making it so /etc/localtime is not stat()-ed repeatedly, which is very inefficient