General TC > Programming & Scripting - Unofficial
Updating TZ through script
Mypresus:
Does anybody know of a way to change the environment variable through scripting? Tried the attached test code however no luck. Thinking it may not be possible as scripts work in their own environment and can not pass to parent, but never know. Thought doesn't hurt to ask. The object of this little project is to change TZ without rebooting.
Any feedback welcome.
Rich:
Hi Mypresus
--- Quote from: Mypresus on June 02, 2022, 10:57:33 PM --- ... The object of this little project is to change TZ without rebooting.
--- End quote ---
I don't know if that's possible. You might check if you can use /etc/timezone and/or /etc/localtime instead of tz.
Mypresus:
Hi Rich,
Thank you for your quick reply and advise. Changing TZ through command prompt works fine for example using "export TZ=UTC" however, using a the script does not change it. Changing both /etc/timezone and/or /etc/localtime files require a reboot to take effect I have played around a bit with using extlinux.conf tz=xxxx and this creates the TZ environment variable and the etc/timezone file. I have also created the TZ through a script in the profile.d which creates the TZ environment variable with no problems (which shifts TZ from sys cmd to the user environment).Once TZ variable is created wanting to change it through a script is the sticking point, it works fine when changing through command prompt. If i can overcome this problem then changing timezone without rebooting becomes possible. Would be nice to add to TC but unfortunately this my not be able to be achieved.
Rich:
Hi Mypresus
--- Quote from: Mypresus on June 03, 2022, 12:15:07 AM --- ... Changing both /etc/timezone and/or /etc/localtime files require a reboot to take effect ...
--- End quote ---
Are you sure? I read somewhere that you should not set tz if using /etc/timezone and/or /etc/localtime.
Changing the link to /etc/localtime should change the time.
Mypresus:
Hi Rich, I will do some further testing to make sure and will let you know, thanks for the update. :D
Navigation
[0] Message Index
[#] Next page
Go to full version