As an organization level change, our Linux server time will be set to UTC.
Our current scripts (ksh & python) use system date heavily which right now is set to EST.
Is there a way to override the time zone of system date without actually changing system clock?
We are trying to handle the upcoming system time change to UTC in best way possible.
So if we can override the system time for a particular user profile that might be ideal.
This way we won't have to manually find each place in every script where date, touchdatetime.datetime.now() (python) or something similar is used.
Is there any other/better way to do this?
Any relevant information would be greatly appreciated.
The time zone is a representation.
Changing it will not affect the system clock.
You can set it temporarily for one process, like
TZ=UTC date
Or set it for the current shell:
export TZ=UTC
date
and perhaps in the user's .bashrc and .profile, then it will be effective for all user processes.
Of course you can change the system default as well (e.g. by the timedatectl command). Then it will be effective for all system processes (including syslog or journald). Eventually they need to be restarted (consider a system reboot).
Thank you for all the information. I'll test this and I think it'll solve our problem.
When I try TZ=UTC date I get date in UTC. But if I run date on next line it prints date in current time zone.
Doing export TZ=UTC does make it permanent and I get UTC time zone when I run date.
timedatectl is not available on our system. Could there be a different command that I can try?
Am I doing something wrong (for 1 above)?
We are on very old version on RHEL, 6.10 so not sure if this is what might be causing both these issues.