|
Prev: What to backup on a Linux system an what not?
Next: How to put a command over SSH in background ?
From: Guillaume Dargaud on 5 May 2008 09:42 OK, let me rephrase that. Why can't I feed the output of the date command to set the date ? For instance something like that: date $( ssh user(a)reference "date" ) Yes, I know I can use +"%m%d%H%M%Y.%s" to output the format expected as input, BUT that still leaves out the problem of the time zone. The command date doesn't seem to set the timezone so that pretty much renders this attempt plain wrong if both machines are not already configured with proper and identical timezone... The closest is: date -u $(ssh guinevere(a)distill "date -u +\"%m%d%H%M%Y.%s\"" ) (yes, I know about ntp, but that's not my question). -- Guillaume Dargaud http://www.gdargaud.net/
From: Bill Marcum on 5 May 2008 10:25 On 2008-05-05, Guillaume Dargaud <use_the_form_on_my_contact_page(a)www.gdargaud.net> wrote: > > > OK, let me rephrase that. > Why can't I feed the output of the date command to set the date ? > > For instance something like that: > date $( ssh user(a)reference "date" ) > > Yes, I know I can use +"%m%d%H%M%Y.%s" to output the format expected as > input, BUT that still leaves out the problem of the time zone. The command > date doesn't seem to set the timezone so that pretty much renders this > attempt plain wrong if both machines are not already configured with proper > and identical timezone... > > The closest is: > date -u $(ssh guinevere(a)distill "date -u +\"%m%d%H%M%Y.%s\"" ) > (yes, I know about ntp, but that's not my question). Doesn't that work, other than a possible second or two of network lag? Or you could try date $(ssh guinivere(a)distill "TZ=yourtimezone date +%m%d%H%M%Y.%s")
From: Guillaume Dargaud on 5 May 2008 11:40 >> date -u $(ssh guinevere(a)distill "date -u +\"%m%d%H%M%Y.%s\"" ) > Doesn't that work, other than a possible second or two of network lag? Well, 'almost': # ssh guinevere(a)distill date; date -u $(ssh guinevere(a)distill "date -u +\"%m%d%H%M%Y.%s\"" ); date; cat /etc/TZ Mon May 5 17:18:05 CEST 2008 Mon May 5 15:18:12 UTC 2008 Mon May 5 15:18:12 UTC 2008 CEST So the time is correct, but the timezone information is ignored. It may be a bug in uClibc. Or maybe I need to tell it explicitely to read TZ... > Or you could try > date $(ssh guinivere(a)distill "TZ=yourtimezone date +%m%d%H%M%Y.%s") Same thing: # date $(ssh guinevere(a)distill "TZ=CEST date +%m%d%H%M%Y.%s") Mon May 5 15:38:12 UTC 2008 date can show the timezone, so why can't it set it ? -- Guillaume Dargaud http://www.gdargaud.net/
From: steven_nospam at Yahoo! Canada on 6 May 2008 17:00 On May 5, 9:42 am, "Guillaume Dargaud" <use_the_form_on_my_contact_p...(a)www.gdargaud.net> wrote: > OK, let me rephrase that. > Why can't I feed the output of the date command to set the date ? > > For instance something like that: > date $( ssh user(a)reference "date" ) > > Yes, I know I can use +"%m%d%H%M%Y.%s" to output the format expected as > input, BUT that still leaves out the problem of the time zone. The command > date doesn't seem to set the timezone so that pretty much renders this > attempt plain wrong if both machines are not already configured with proper > and identical timezone... > > The closest is: > date -u $(ssh guinevere(a)distill "date -u +\"%m%d%H%M%Y.%s\"" ) > > (yes, I know about ntp, but that's not my question). > -- > Guillaume Dargaudhttp://www.gdargaud.net/ Have you considered "setclock"? Simply issue "setclock PrimaryServer" while logged on to any other server in your network and those servers will attempt to get the right time from the PrimaryServer system. This is useful when you want to keep many UNIX hosts synchronized with the same time on one network. Example: we have an Oracle primary and standby server, and we like to keep the time the same on both so that the archive logs and date/time stamps of everything are going to match within a few seconds of each other. So we run "setclock" in the root crontab every night at a designated time.
From: Jon LaBadie on 6 May 2008 07:29 Guillaume Dargaud wrote: >>> date -u $(ssh guinevere(a)distill "date -u +\"%m%d%H%M%Y.%s\"" ) > >> Doesn't that work, other than a possible second or two of network lag? > > Well, 'almost': > # ssh guinevere(a)distill date; date -u $(ssh guinevere(a)distill "date -u > +\"%m%d%H%M%Y.%s\"" ); date; cat /etc/TZ > Mon May 5 17:18:05 CEST 2008 > Mon May 5 15:18:12 UTC 2008 > Mon May 5 15:18:12 UTC 2008 > CEST > > So the time is correct, but the timezone information is ignored. It may be a > bug in uClibc. Or maybe I need to tell it explicitely to read TZ... > >> Or you could try >> date $(ssh guinivere(a)distill "TZ=yourtimezone date +%m%d%H%M%Y.%s") > > Same thing: > # date $(ssh guinevere(a)distill "TZ=CEST date +%m%d%H%M%Y.%s") > Mon May 5 15:38:12 UTC 2008 > > > date can show the timezone, so why can't it set it ? Typically date/time is stored in the system clock as if it were UTC. Each process then can have its own concept of in which TZ that process is running. The representation of the UTC date/time can then be presented in which ever format the user chooses. But all the processes are working on the same date/time basis, UTC. At login your processes pick up their concept of a timezone in some way, maybe from /etc/localtime, or /etc/TZ, or /etc/default/??, or ??? I don't know your OS, so I don't know how your system does it. Once set, the timezone information for a process is part of its environment, not part of the systems environment, just that process. And as for exported variables, a child process can not affect the environment of its parent. So running date can change the hardware clock or the kernels copy of its value because it is specifically written to do that. But it can not change your shells timezone environment setting. BTW I don't recognize CEST as a timezone and my zoneinfo files do not show such a file name. The tzset man page notes that if the environment setting for the timezone is not recognized it defaults to UTC. Might that be the reason you keep seeing UTC output from date?
|
Next
|
Last
Pages: 1 2 Prev: What to backup on a Linux system an what not? Next: How to put a command over SSH in background ? |