[Lxc-users] uptime

Ulli Horlacher framstag at rus.uni-stuttgart.de
Mon May 14 16:14:23 UTC 2012


On Mon 2012-05-14 (11:57), Papp Tamas wrote:

> > I have now written a special uptime command to be placed in the containers
> > PATH:
> >
> > #!/usr/bin/perl -w
> >
> > $uptime = `/usr/bin/uptime`;
> > @s = lstat '/dev/pts' or die $uptime;
> > $s = time - $s[10];
> > if ($s>172800) {
> >    $d = int($s/86400);
> >    $uptime =~ s/up .*?,/up $d days,/;
> > } else {
> >    $h = int($s/3600);
> >    $m = int(($s-$h*3600)/60);
> >    $uptime =~ s/up .*?,/sprintf("up %02d:%02d,",$h,$m)/e;
> > }
> > print $uptime;
> 
> Does this work for you?

Of course. I do not post non-functional code.


> Not for me.

Error message?


-- 
Ullrich Horlacher              Server- und Arbeitsplatzsysteme
Rechenzentrum                  E-Mail: horlacher at rus.uni-stuttgart.de
Universitaet Stuttgart         Tel:    ++49-711-685-65868
Allmandring 30                 Fax:    ++49-711-682357
70550 Stuttgart (Germany)      WWW:    http://www.rus.uni-stuttgart.de/
REF: <4FB0D718.2050905 at martos.bme.hu>




More information about the lxc-users mailing list