Usenet comp.os.linux.alpha (1997-2013)
 help / color / mirror / Atom feed
* How can I change year 2018 to 1998
@ 1998-10-13  4:00 G. Hugh SONG
  1998-10-15  4:00 ` Robert Harley
  1998-10-16  4:00 ` Joseph Sarkes
  0 siblings, 2 replies; 8+ messages in thread
From: G. Hugh SONG @ 1998-10-13  4:00 UTC (permalink / raw)


Hi,

I installed the RedHat 5.1 on a fresh hard.
Oh, no!   All the links and the directories are dated at year 2018.
How can I fix this?  The month and day are all right.

I really do not want to reinstall the system, because I configured
the system quite significantly already.
Besides, I knew that I have to cold reboot all the time.  But during
installation, I really don't remember whether I was given any
chance to cold-reboot.  I think I just followed the installation
procedure.

I have "clock-pc164-rh50" program from Digital.  But there is no
document for it.  What does this program do?  There is no DOS
mode to run this kind of program here.

My system is LX164.

Thank you very much.
--
G. Hugh Song

PS: Please remove "Spamspoiler" when replying





^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: How can I change year 2018 to 1998
  1998-10-13  4:00 How can I change year 2018 to 1998 G. Hugh SONG
@ 1998-10-15  4:00 ` Robert Harley
  1998-10-16  4:00   ` Michal Jaegermann
  1998-10-16  4:00   ` Tan Wee Yeh
  1998-10-16  4:00 ` Joseph Sarkes
  1 sibling, 2 replies; 8+ messages in thread
From: Robert Harley @ 1998-10-15  4:00 UTC (permalink / raw)



"G. Hugh SONG" <ghsong@\"Spamspoiler\"kjist.ac.kr> writes:
> I installed the RedHat 5.1 on a fresh hard.
> Oh, no!   All the links and the directories are dated at year 2018.
> How can I fix this?  The month and day are all right.

I wrote a tiny program called "chyear":

syntax: ./chyear -(-a|-m) <filename> <from year> <to year>
  If access (-a) or modification (-m) time of <filename>
  falls in <from year>, it is changed to <to year>.


You can use it to do stuff like:

  foreach file ( `find . -mtime -0 -print` )
  chyear -m $file 2018 1998
  end


Source at:

  http://pauillac.inria.fr/~harley/tmp/chyear.c


Disclaimer: No warranty etc.

Bye,
  Rob.



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: How can I change year 2018 to 1998
  1998-10-15  4:00 ` Robert Harley
@ 1998-10-16  4:00   ` Michal Jaegermann
  1998-10-19  4:00     ` Robert Harley
  1998-10-16  4:00   ` Tan Wee Yeh
  1 sibling, 1 reply; 8+ messages in thread
From: Michal Jaegermann @ 1998-10-16  4:00 UTC (permalink / raw)


Robert Harley (harley@corton.inria.fr) wrote:

: > How can I fix this?  The month and day are all right.

: I wrote a tiny program called "chyear":

Unfortunately it has two problems.  One - it is using 'stat'
instead of 'lstat' so it will dereference symbolic links.
Two - even if you will look at a link and not an underlying inode
then 'utime' seems to follow links as well.  Sigh!  Frankly, I do
not know if the later is a required behaviour or bug in glibc.
Manpage seem to suggest a bug; it does not say anything about
links but talks in terms of inodes.

If you do not care about dates on links then 'touch' will work
equally well without writing any C and compiling anything.  Type
'touch --help' to see for yourself. :-)  It will even do multiple
files in one go instead of walking them one-by-one.

  Michal



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: How can I change year 2018 to 1998
  1998-10-13  4:00 How can I change year 2018 to 1998 G. Hugh SONG
  1998-10-15  4:00 ` Robert Harley
@ 1998-10-16  4:00 ` Joseph Sarkes
  1 sibling, 0 replies; 8+ messages in thread
From: Joseph Sarkes @ 1998-10-16  4:00 UTC (permalink / raw)


G. Hugh SONG (ghsong@\"Spamspoiler\"kjist.ac.kr) wrote:
: Hi,

: I installed the RedHat 5.1 on a fresh hard.
: Oh, no!   All the links and the directories are dated at year 2018.
: How can I fix this?  The month and day are all right.

My system is a multia, but probably is similar to what you are
running into. If you are booting linux from the ARC firmware, you
need to specify that the clock is in the ARC format. That is where
your 20 year offset is coming from. Another problem that occurs is
that there is a bug in clock (at least with arc/multia) where it
doesn't set the time properly on boot, and i was losing something
like 4 years every boot. By removing a flag from the clock command
in the startup script i fixed that. You probably need a ARC=true in
your /etc/sysconfig/clock file.

As far as fixing the dates on all your directories, you can probably
do a find . -type d -exec touch --time=whatever {} \; 
or similar incantation.


--
Joseph Sarkes                   mailto:joe@mediaone.net



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: How can I change year 2018 to 1998
  1998-10-15  4:00 ` Robert Harley
  1998-10-16  4:00   ` Michal Jaegermann
@ 1998-10-16  4:00   ` Tan Wee Yeh
  1998-10-16  4:00     ` Alex Rhomberg
  1 sibling, 1 reply; 8+ messages in thread
From: Tan Wee Yeh @ 1998-10-16  4:00 UTC (permalink / raw)


Robert Harley <harley@corton.inria.fr> wrote:

>   foreach file ( `find . -mtime -0 -print` )
>   chyear -m $file 2018 1998
>   end

Correct me if I'm wrong but

# find . -mtime -0 -exec chyear -m {} 2018 1998 \;

would probably be more efficient :).


-- 
Just me,
Wire ...



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: How can I change year 2018 to 1998
  1998-10-16  4:00   ` Tan Wee Yeh
@ 1998-10-16  4:00     ` Alex Rhomberg
  0 siblings, 0 replies; 8+ messages in thread
From: Alex Rhomberg @ 1998-10-16  4:00 UTC (permalink / raw)
  To: Tan Wee Yeh, G. Hugh SONG

[-- Attachment #1: Type: text/plain, Size: 1375 bytes --]

Tan Wee Yeh wrote:
> 
> Robert Harley <harley@corton.inria.fr> wrote:
> 
> >   foreach file ( `find . -mtime -0 -print` )
> >   chyear -m $file 2018 1998
> >   end
> 
> Correct me if I'm wrong but
> 
> # find . -mtime -0 -exec chyear -m {} 2018 1998 \;
> 
> would probably be more efficient :).

Both methods are very inefficient, because the chyear program has to be
started freshly for every file, resulting in high system cpu usage.
It's better to modify the program so it accepts any number of filenames
as arguments or reads them from stdin like the file I attached. This
way, the find results can be piped or backticked, resulting in only a
single call each of chyear and find.
I try to avoid -exec in find calls.

use
find . -mtime  -0 |chyear 2018 1998
or
chyear 2018 1998 `find . -mtime -0 -mount`

- Alex

-- 
  _________________________________________________________________
 /                                                                 \
|  Alex Rhomberg                           Tel: +41 1 632 49 18     |
|  Institut fuer Elektronik                Fax: +41 1 632 12 10     |
|  ETH Zuerich                        Zentrale: +41 1 632 11 11     |
|  Gloriastrasse 35                                                 |
|  8092 Zuerich               email: rhomberg@ife.ee.ethz.ch        |
 \_________________________________________________________________/

[-- Attachment #2: chyear --]
[-- Type: text/plain, Size: 2053 bytes --]

#!/usr/bin/perl -w

# chyear
# changes access or modification year of a file
# based on a program of Robert Harley
# Author: Alex Rhomberg <rhomberg@ife.ee.ethz.ch>

#usage: first come the options (-a to modify access, -m to modify modify time)
#then comes fromyear, then toyear, then the filenames
#filenames can also be supplied through stdin

#examples:
#touch /tmp/now; find / -newer /tmp/now |chyear 2038 1998; rm /tmp/now
#touch /tmp/now; chyear 2038 1998 `find / -newer /tmp/now`; rm /tmp/now

my $usage = 
  "Usage: $0 [-m] [-a] <fromyear> <toyear> [<file1> [<file2> [...]]]\n".
  "\t-m modifies modify time, -a the access time\n".
  "if no option is given, both times are modified\n".
  "if no filename is given, they are taken from stdin\n";

use POSIX; # needed for mktime

die $usage if $#ARGV < 1;

my ($modacc, $modmod) = (0,0);

while ($ARGV[0] =~ /^-(.*)$/) {
  shift;
  $modacc = 1 if $1 eq 'a';
  $modmod = 1 if $1 eq 'm';
  die $usage unless $1 =~ /^[am]$/;
}

$modacc = $modmod = 1 unless $modacc||$modmod;

die $usage if $#ARGV < 1;

my $fromyear = shift;
my $toyear = shift;

die "$0: years are strange\n" if (($fromyear < 1970) || ($fromyear > 2037) ||
				  ($toyear   < 1970) || ($toyear   > 2037));

if (@ARGV) {
  while(@ARGV) {
    $_ = shift;
    chyear($fromyear, $toyear, $_) unless -l $_;
  }
} else {
  while (<>) {
    chomp;
    chyear($fromyear, $toyear, $_) unless -l $_;
  }
}

sub chyear {
  my $fy = shift() - 1900;
  my $ty = shift() - 1900;
  my $file = shift;

  my ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,
      $atime,$mtime,$ctime,$blksize,$blocks)
    = lstat($file);

  my @time = localtime ($atime);

  my $mod = 0;

  if($modacc) {
    if ($time[5] == $fy) {
      $time[5] = $ty;
      $atime = mktime(@time);
      
      $mod = 1;
    }
  }

  @time = localtime($mtime);

  if($modmod) {
    if ($time[5] == $fy) {
      $time[5] = $ty;
      $mtime = mktime(@time);
      
      $mod = 1;
    }
  }
  
  if ($mod) {
    print "changing $file\n";
    utime $atime, $mtime, $file if $mod;
  }
}

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: How can I change year 2018 to 1998
  1998-10-16  4:00   ` Michal Jaegermann
@ 1998-10-19  4:00     ` Robert Harley
  1998-10-19  4:00       ` Michal Jaegermann
  0 siblings, 1 reply; 8+ messages in thread
From: Robert Harley @ 1998-10-19  4:00 UTC (permalink / raw)



michal@gortel.phys.ualberta.ca (Michal Jaegermann) writes:
> [...chyear.c...]
> Unfortunately it has two problems.  One - it is using 'stat'
> instead of 'lstat' so it will dereference symbolic links.
> Two - even if you will look at a link and not an underlying inode
> then 'utime' seems to follow links as well.

As far as I can remember, I originally had lstat(), but since utime()
seems to always follow links I switched to stat() for consistency.
So 'chyear' follows links.  That's a feature!  ;-)


> If you do not care about dates on links then 'touch' will work
> equally well without writing any C and compiling anything.

No way Jos�.  The whole point is to move bunches of files from the
future back to the past without messing up the order of their time
stamps relative to one another.  If you care about versioning,
makefiles or just want to know "which version of that project is the
most recent?", it's best not to throw away all timestamp information
with 'touch'.  IMHO.

Bye,
  Rob.



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: How can I change year 2018 to 1998
  1998-10-19  4:00     ` Robert Harley
@ 1998-10-19  4:00       ` Michal Jaegermann
  0 siblings, 0 replies; 8+ messages in thread
From: Michal Jaegermann @ 1998-10-19  4:00 UTC (permalink / raw)


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 1286 bytes --]

Robert Harley (harley@corton.inria.fr) wrote:

: > If you do not care about dates on links then 'touch' will work
: > equally well without writing any C and compiling anything.

: No way Jos�.  The whole point is to move bunches of files from the
: future back to the past without messing up the order of their time
: stamps relative to one another.

I do not follow. 'touch' is absolutely capable of changing only a year
- exactly the same way as 'chyear' does.  At least this version you
have on your machine.  Once again - type 'touch --help'.

: If you care about versioning,
: makefiles or just want to know "which version of that project is the
: most recent?",

As I normally run 'touch' as a part of an installation process,
immediately after a system clock is sane, and only touch files with
dates in the future then the above is a non-existing problem.

: it's best not to throw away all timestamp information
: with 'touch'.  IMHO.

There is none yet but you may set date to anything you want anyway.
Just a few lines of shell/perl/awk (take your pick).

This still leaves us with weird dates on links.  Big sigh!  The only
way I know is to delete a link and recreate it.  I am not going to do
that automatically as quite a few of these links are to libraries.

  Michal



^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~1998-10-19  4:00 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
1998-10-13  4:00 How can I change year 2018 to 1998 G. Hugh SONG
1998-10-15  4:00 ` Robert Harley
1998-10-16  4:00   ` Michal Jaegermann
1998-10-19  4:00     ` Robert Harley
1998-10-19  4:00       ` Michal Jaegermann
1998-10-16  4:00   ` Tan Wee Yeh
1998-10-16  4:00     ` Alex Rhomberg
1998-10-16  4:00 ` Joseph Sarkes

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox