LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Debian (https://www.linuxquestions.org/questions/debian-26/)
-   -   time not match (https://www.linuxquestions.org/questions/debian-26/time-not-match-569955/)

pk_kala 07-16-2007 09:53 PM

time not match
 
time at syslog not match with machine

localhost:/var/log# tail -f messages
Jul 16 19:38:15 localhost -- MARK --
Jul 16 19:58:15 localhost -- MARK --

localhost:~# date
Tue Jul 17 09:49:51 ICT 2007

how I resolve?
Thank you

wjevans_7d1@yahoo.co 07-18-2007 07:50 AM

I'm not an expert in this, but nobody has been answering this question, so I'll give it a shot.

pk_kala, there are two ways to specify the applicable time zone: the default way and an optional way.

If you have not used the optional way (which I'll describe in a moment), the default way is via file /etc/localtime. It's typically a symbolic link to some specific time zone file. Here's what happens on my machine:

Code:

wally:~$ ls -l /etc/localtime
lrwxrwxrwx    1 root    root          30 Mar 11 10:39 /etc/localtime -> /usr/share/zoneinfo/US/Pacific
wally:~$

Try it on your machine to see what your default time zone is. That time zone applies for all requests for the local time of day, unless a specific process is using a different time zone. (I'm guessing here that your syslogd is not using a different time zone.) So when you try the above command on your machine, you're likely to get the time zone used by syslogd.

I'm about to describe the optional way to set the time zone, as I promised above.

A specific process (and all its children) can request the use of a different timezone from that specified by /etc/localtime by setting the TZ environment variable. (TZ stands for "time zone".) This can be done automatically for you, for example, by your shell setup files. You can tell whether you have set TZ by doing this at the shell prompt:

Code:

env | grep '^TZ='
If you get no output, then TZ is not set. If you get output, you get the name of the time zone which applies while you're running your shell. This is normally set by the usual shell initialization files (which I'll discuss later), but you can change it manually while you're running your shell.

I normally don't specify TZ. Here's what happens when I play with that:

Code:

wally:~$ ls -l /etc/localtime
lrwxrwxrwx    1 root    root          30 Mar 11 10:39 /etc/localtime -> /usr/share/zoneinfo/US/Pacific
wally:~$ # On the above line is the time zone which applies if TZ is not set.
wally:~$ env | grep '^TZ='
wally:~$ # Since the above line gave no output, I know that TZ is not set.
wally:~$ date
Wed Jul 18 05:40:23 PDT 2007
wally:~$ # Notice that the timezone used is, indeed, the Pacific timezone.
wally:~$ export TZ="US/Central"
wally:~$ env | grep '^TZ='
TZ=US/Central
wally:~$ date
Wed Jul 18 07:41:06 CDT 2007
wally:~$ unset TZ
wally:~$ env | grep '^TZ='
wally:~$ date
Wed Jul 18 05:41:28 PDT 2007
wally:~$

Do the same thing yourself and see what happens.

Finally, as I've promised, I'll discuss how TZ could be set automatically for you, without you knowing it.

If the shell you're running is bash (which is true for most Linux users), check the content of the following files. Not all of them exist, but check the ones that do exist:
  1. /etc/profile
  2. in your home directory, .bash_profile
  3. in your home directory, .profile
  4. in your home directory, .bashrc

The period (".") in three of the filenames is important; do not omit it.

If you're running some shell other than bash, check the documentation for that shell.

Hope this helps.

farslayer 07-18-2007 08:11 AM

My guess would have been that the logging service hasn't been restarted since the system time was changed.. so restarting the logging service would probably sync it's time up to the system time. I have seen this problem before on one of my systems but I can not recall how I fixed it .. reboot ? Restart the services that were logging?

Either way it definitely appeared after I changed the system time.

I don't think it's a time zone issues since the listed Timezone is ICT which is a +4 offset and the disparity in the log time vs the system time is only 2 - 2.5 hours or so...

I'd be interested to know the solution you find PK_Kala.. my searching came up empty when I tried to verify my answer about the services that are logging needing to be restarted.

wjevans_7d1@yahoo.co 07-19-2007 05:39 AM

Quoth farslayer:

Quote:

My guess would have been that the logging service hasn't been restarted since the system time was changed ...
Either way it definitely appeared after I changed the system time.
Well, I tried that just now. I changed the time (as root), thus:

Code:

root:~# date -s 'July 20'
Fri Jul 20 00:00:00 PDT 2007
root:~#

... and then opened a new xterm window as root. The three most recent entries in the system log are these:

Code:

Jul 19 03:33:18 tiger pwdauth[27146]: user `root' entered correct password for `root'.
Jul 19 03:33:40 tiger pwdauth[27175]: user `root' entered correct password for `root'.
Jul 20 00:00:10 tiger pwdauth[27220]: user `root' entered correct password for `root'.

... so I'm leaning toward the time zone theory.


All times are GMT -5. The time now is 08:47 AM.