LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Debian
User Name
Password
Debian This forum is for the discussion of Debian Linux.

Notices


Reply
  Search this Thread
Old 07-16-2007, 09:53 PM   #1
pk_kala
Member
 
Registered: Feb 2006
Posts: 34

Rep: Reputation: 15
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
 
Old 07-18-2007, 07:50 AM   #2
wjevans_7d1@yahoo.co
Member
 
Registered: Jun 2006
Location: Mariposa
Distribution: Slackware 9.1
Posts: 938

Rep: Reputation: 31
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.
 
Old 07-18-2007, 08:11 AM   #3
farslayer
LQ Guru
 
Registered: Oct 2005
Location: Northeast Ohio
Distribution: linuxdebian
Posts: 7,249
Blog Entries: 5

Rep: Reputation: 191Reputation: 191
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.
 
Old 07-19-2007, 05:39 AM   #4
wjevans_7d1@yahoo.co
Member
 
Registered: Jun 2006
Location: Mariposa
Distribution: Slackware 9.1
Posts: 938

Rep: Reputation: 31
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.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
grep/sed/awk - find match, then match on next line gctaylor1 Programming 3 07-11-2007 08:55 AM
System time vs Hardware time and Daylight Savings Time Toadman Linux - General 6 03-17-2007 08:12 AM
System time vs Hardware time and Daylight Savings Time Toadman Linux - Networking 6 03-16-2007 07:14 PM
Music Match ..Help Please Hilloki Linux - Software 4 03-08-2004 06:03 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Debian

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

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration