Operating System - HP-UX
1822776 Members
4069 Online
109645 Solutions
New Discussion юеВ

date stamp of DEC 31 1969

 
david.deng
Occasional Advisor

date stamp of DEC 31 1969

I found there are some files have the date of DEC 31 1969. I use "ls -l", it shows the wrong date DEC 31 1969. When I use "ls -alstc" it shows the correct date. Why???
10 REPLIES 10
James R. Ferguson
Acclaimed Contributor

Re: date stamp of DEC 31 1969

Hi David:

Using 'ls -l' means show the *mtime* (modifcation) timestamp. Using 'ls -lc' means show the *ctime* or inode change timestamp.

That said, your file was last modified at or very near the Epoch (January 1, 1970) where the number of seconds begins at zero. In your case, your TZ (timezone) offset is some hours west of GMT since you live in Canada. Thus your *mtime* is offset a few hours *less* than GMT yielding a date slightly less than January 1, 1970. The last inode change time is a current value and hence converts to a current date.

There is nothing really amiss here.

Regards!

...JRF...
david.deng
Occasional Advisor

Re: date stamp of DEC 31 1969

Thanks JRF. The file was created today and was not modified. How it has the wrong modify date? The content in the file is OK. However, the wrong date is confusing. The file was exported from database. This happens only sometimes. Anyway to solve this problem?
Peter Godron
Honored Contributor

Re: date stamp of DEC 31 1969

Hi David,
and welcoem to the forums !
Are these files by any chance on an NFS system ? There can be mis-interpretations of timestamps via NFS.
James R. Ferguson
Acclaimed Contributor

Re: date stamp of DEC 31 1969

Hi David:

You can create or modify a file with any valid timestamp you wish with 'touch'. This uses the underlying 'utime(2') system call to affect the change. A C program or Perl also has the abiility to use 'utime()' directly.

You can change the *mtime* of the file to the current date and time merely by doing:

# touch myfile

If you want to set the *mtime* to say, January 22, 2007 at 0700, localtime, do:

# touch 200701220700 myfile

See the manpages for 'touch(1)' and 'stat(2)' for more information.

Regards!

...JRF...

James R. Ferguson
Acclaimed Contributor

Re: date stamp of DEC 31 1969

HI David:

Oops, that should have been:

...if you want to set the *mtime* to say, January 22, 2007 at 0700, localtime, do:

# touch -mt 200701220700 myfile

Regards!

...JRF...

david.deng
Occasional Advisor

Re: date stamp of DEC 31 1969

Anyone know the reason why the file has the wrong modify date? Thanks ahead.
Bill Hassell
Honored Contributor

Re: date stamp of DEC 31 1969

To amplify on how easy it is to modify the timestamp, the culprit is the program that created the file. Go after your database vendor to fix some sloppy coding.


Bill Hassell, sysadmin
A. Clay Stephenson
Acclaimed Contributor

Re: date stamp of DEC 31 1969

Without knowing precisely how the file is created or modified, it's simply not possible to explain why mtime is being set to 0. It's possible that gettimeofday is being called with an uninitized pointer so the the results vary with what happens to be on the stack at the time of the call. You would have to probe your code to see what is actually happening.
If it ain't broke, I can fix that.
david.deng
Occasional Advisor

Re: date stamp of DEC 31 1969

There is a very old database software ABLIX running on HP-UX 11.i. The file was created by "a database command which shows some data" > filename. I am wondering how the ">" got an file with wrong date.
James R. Ferguson
Acclaimed Contributor

Re: date stamp of DEC 31 1969

Hi (again) David:

> There is a very old database software ABLIX running on HP-UX 11.i. The file was created by "a database command which shows some data" > filename. I am wondering how the ">" got an file with wrong date.

You are assuming that the redirection is the *last* operation performed on 'filename'. As I indicated, the system call 'utime()' can be used to alter the access and/or modification timestamp. A zero (0) argument for either is perfectly legal. As noted, you really need to peek at the underlying code.

Regards!

...JRF...