Simple PHP Web uptime script

by Ruchira on December 5, 2010

Having 100s days of server uptime with your shiny linux box? Wanna showoff like I want to do? 😛 Or want to monitor server uptime without SSHing to server? There is nice way to showoff your uptime in simple PHP script which requires nothing fancy changes on your linux box. Ill will display system time load averages and uptime in simple layout.

You just want to do is create a .php file in your notepad and enter this syntax on notepad

<?PHP system('uptime'); ?>

When saving dont forget to choose “all files” and then name it whatever you want end in .php as file name.
ex- uptime.php and then move the saved file to your server path. ex-

If you are too lazt to create the php file on notepad just download the uptime.php file here and unrar it and put in to your web site directory.

Thats it.

See it live on

I'm Ruchira Sahan and all posts on this blog are completely my thoughts and writings. I love DIY and Technology. So feel free to contact me for anything about this blog and don't forget to add a comment if this blog helped you! Thanks
View all posts by Ruchira

{ 4 comments… read them below or add one }

1 Ken July 31, 2011 at 9:21 PM

I was looking for something like this for a CMS/web site I’m building. After I spent a couple of days obsessively writing PHP, a language I was not yet much good at, I churned this out, and improved m PHP coding skills tremendously! It’s a bit verbose in its capabilities, but it will return just about any output you need from ‘uptime’.

SCRIPT NAME: PHP System Uptime
FILE NAME: phpuptime.php
PURPOSE: Processes the output of the Linux 'uptime' command to render it easier to use in a PHP script.
uptime() – returns the system uptime
uptime(uptime) – same effect as uptime()
uptime(users) – returns the number of users currently logged in the format of "X users"
uptime(numeric) – returns only the numerical value number of users currently logged in
uptime(load) – return the system load for the last one, five and fifteen minutes
uptime(load_one_min) – return the system load for the last minute
uptime(load_five_min) – return the system load for the last five minutes
uptime(load_fifteen_min) – return the system load for the last fifteen minutes

OTHER INFO: Use require() to include this script in a PHP document and to make direct calls to the uptime() function.
You must supply the correct path to phpuptime.php, as per your directory structure. It is advised that
you use require(), and not include(), as require() is considered to be a more safe function than include().


// This is an example of how to use the uptime() function. It demonstrates several methods of use for this function.

$br = "”;

print phpuptime() . $br;
print phpuptime(uptime) . $br;
print phpuptime(users) . $br;
print phpuptime(users_numeric) . $br;
print phpuptime(load) . $br;
print phpuptime(load_five_min) . $br;
print phpuptime(load_one_min) . $br;
print phpuptime(load_fifteen_min) . $br;


2 Ken July 31, 2011 at 9:23 PM

Some of the code was cut out from my last post. I’m not sure if it is because it is awaiting moderation, if the blogging software chopped it out, or if it was my own user error. Either way, I apologize if it does not post once approved 🙂


3 Daniel August 19, 2012 at 9:14 AM

how would this be possible to work as a widget ?

im using wordpressblog note the content is in danish language i like your script but culd really use it as widget on my blog !

my personal link site


4 Ruchira August 24, 2012 at 1:33 AM

I see you have achieved this 🙂


Leave a Comment

Previous post:

Next post: