Re: Scripted method to change TZ from UTC to a specific timezone?



On Friday 15 October 2010 10:45:27 James Wu wrote:
When I run the cmd "date", I get UTC time on a fresh boot of an imaged
machine. I'd like to find a way to set the time to "America/New_York"
for automatically via script. A reboot is ok if absolutely needed but
not preferred.

I'm aware that I can run "dpkg-reconfigure tzdata" but that requires
user input.

Depends on what frontend you use.

I've tried the following methods without success:
"cp /usr/share/zoneinfo/America/New_York /etc/timezone"

Wrong file. /etc/timezone is just cosmetic, AFAIK. The target of your cp
command should have been /etc/localtime.

+ changing
"UTC=yes to UTC=no" in /etc/default/rcS

From what I understand, that only affect where

I've also tried "echo 'America/New_York' > /etc/timezone" as well
instead of copying.

You might also want to do this, but /etc/localtime and /etc/timezone provide
different information. /etc/localtime is machine-readable data that allows
libc to map UTC times to local times; /etc/timezone is (I guess) the human-
readable name of the local time.

You shouldn't need to reboot; updates to /etc/localtime and /etc/timezone are
automatically picked up by libc.

Is there another way to change the tzdata from
UTC without requiring user input?

debconf-set-selections < $some_configs_in_a_file
dpkg-reconfigure -fnoninteractive "$changed_packages[@]"

Maybe?
--
Boyd Stephen Smith Jr. ,= ,-_-. =.
bss@xxxxxxxxxxxxxxxxx ((_/)o o(\_))
ICQ: 514984 YM/AIM: DaTwinkDaddy `-'(. .)`-'
http://iguanasuicide.net/ \_/

Attachment: signature.asc
Description: This is a digitally signed message part.



Relevant Pages

  • Re: State of Forth 200x
    ... user input *is* source code. ... The script is essentially one-time user input. ... The dialect I use is a concatenative language with flow control, ... the command language is the full compiled language, ...
    (comp.lang.forth)
  • Re: trouble with a script
    ... The user input would be "domain.com", ... Basically, I want my script to prompt me for two inputs, then append to ... have tried many ways to write a newline character in the script, ... Shell Scripting Recipes: ...
    (comp.unix.shell)
  • Re: Securing an Email script
    ... The main issue I'm wondering about is if I control the to and from address and header information for the mail, as I do above, is it possible to inject something else into the email to hijack the mail server? ... Well, you're placing anything in the header which comes from the user, so in that respect your script is safe. ... However, just to be safe, you should verify the data input by the user. ... > 1) the script is safe because no user input is used in the header. ...
    (comp.lang.php)
  • Re: A script for accepting defaults
    ... the installation script from this file. ... explicitly enumerated user input, ... which will interpose itself before the read builtin command, ...
    (comp.unix.shell)
  • Re: Environment variables with Newlines
    ... malformed header from script. ... This is where the user gets a message that the form data has been processed. ... But the details depend on how newlines in textarea are supposed to affect the outcome. ... If you really want to preserve the exact division into lines in the user input, then you could use markup. ...
    (alt.html)