Re: Set environment variable globally
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 signature.asc Description: OpenPGP digital signature -- Ubuntu-devel-discuss mailing list Ubuntu-devel-discuss@lists.ubuntu.com Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-devel-discuss
Re: Set environment variable globally
On 2017-04-05 20:30, Andrew Martin wrote: From: "Gérard BIGOT" I added this line in /etc/environment since a long time : TZ="Europe/Paris" It gives me satisfaction. I can't seem to get this to work on 16.04. Which shell are you using? Have you customized your /etc/bash.bashrc or /etc/profile to source /etc/environment? I don't see any mention of /etc/environment in the bash manpage, so it seems like this file isn't being used. Also, how can I make this environment variable available to all processes started by upstart (14.04) and systemd (16.04)? I am concerned not only about interactive processes but also scripts (e.g. started via cron) and services (started via upstart or systemd). /etc/environment is not a script file; it's read by PAM. But I don't think that happens early enough for services etc. -- Gunnar Hjalmarsson https://launchpad.net/~gunnarhj -- Ubuntu-devel-discuss mailing list Ubuntu-devel-discuss@lists.ubuntu.com Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-devel-discuss
Re: Set environment variable globally
- Original Message - > From: "Gérard BIGOT" > To: "amartin" > Cc: "ubuntu-devel-discuss" > Sent: Friday, March 31, 2017 8:41:36 AM > Subject: Re: Set environment variable globally > Hi, > > I added this line in /etc/environment since a long time : > > TZ="Europe/Paris" > > It gives me satisfaction. > > With this line, upon reboot, I have : > > ~$ echo $TZ > Europe/Paris > > Without TZ doesn't exist. > Gérard, I can't seem to get this to work on 16.04. Which shell are you using? Have you customized your /etc/bash.bashrc or /etc/profile to source /etc/environment? I don't see any mention of /etc/environment in the bash manpage, so it seems like this file isn't being used. Also, how can I make this environment variable available to all processes started by upstart (14.04) and systemd (16.04)? I am concerned not only about interactive processes but also scripts (e.g. started via cron) and services (started via upstart or systemd). Thanks, Andrew -- Ubuntu-devel-discuss mailing list Ubuntu-devel-discuss@lists.ubuntu.com Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-devel-discuss