develooper Front page | perl.beginners | Postings from December 2010

Re: Linux Uptime

Thread Previous | Thread Next
From:
Alan Haggai Alavi
Date:
December 16, 2010 21:31
Subject:
Re: Linux Uptime
Message ID:
20101217053055.20207.qmail@lists-nntp.develooper.com
Matt wrote:

> I have a perl script but I want to exit it if the uptime on the 
server
> is less then say an hour.  Any idea how I would get uptime with 
perl?


Hi,

You could use the distribution: Unix::Uptime 
(http://search.cpan.org/perldoc?Unix::Uptime)

Example:

use strict;
use warnings;

use Unix::Uptime;

my $uptime_hours = Unix::Uptime->uptime() / 3600;
if ( $uptime_hours < 1 ) {
    exit(127);
}

Regards,
Alan Haggai Alavi.
-- 
The difference makes the difference.

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About