Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

Typically, I set the timezone of my computer's clock by changing the .bashrc file, appending, say, TZ='America/Los_Angeles'; export TZ such that whenever date is invoked the right time in the right timezone is returned. However, after probing awesome, it seems that running echo $TZ in awesome returns something other than when I run echo $TZ in my own terminal.

According to any instance of a lua repl, echo $TZ also appears to return the correct timezone (in accordance with the .bashrc).

How would I go about synchronising the timezones across the programs?

share|improve this question
1  
Is there a particular reason that you're not setting the system-wide timezone? –  cpast Jan 6 '13 at 19:56

1 Answer 1

up vote 4 down vote accepted

Your problem is that you are not defining the environment variable TZ in the right file. ~/.bashrc is the configuration file for interactive shells. It's the place for aliases, key bindings and other things that you want to have in interactive shell. While you can define an environment variable there, this variable will only be set in the programs that are started from an interactive shell. This excluded your window manager and any program started by the window manager.

So instead define environment variables in the proper place. For non-graphical logins, the proper place is ~/.profile. When you log in in graphical mode, the proper place depends on your distribution, your display manager and your session or window manager. On Ubuntu, I believe that all display managers are set up to read ~/.profile as well. So define environment variables in ~/.profile.

This topic has come up many times — see Alternative to .bashrc

In your situation, an alternative possibility is to define the environment variable in your Awesome configuration file (os.setenv('TZ', 'America/Los_Angeles')). Awesome would be the right place to act if you want to change the timezone without logging out and back in (if you're travelling with your laptop).

share|improve this answer
    
Thanks, I didn't realise changing it in .profile required a reboot! –  Soyuz Jan 7 '13 at 4:56
    
@Soyuz Not a reboot, only logging out and back it. If you have admin rights, it's easier to change the timezone at the system level, by changing /etc/localtime. –  Gilles Jan 7 '13 at 9:48

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.