Solved

Apache uptime to web page

Posted on 2004-04-30
3
423 Views
Last Modified: 2008-03-03
I would like to display the time Apache (v2.0) has been running to my statistics web page, can anyone tell me were this information is stored and how I can retrieve it, I have PHP installed as well and would ideally like to use it to solve this problem.

Many thanks  
0
Comment
Question by:duckp
3 Comments
 
LVL 10

Accepted Solution

by:
Mercantilum earned 125 total points
Comment Utility
You are talking about the uptime of Apache, not the uptime of the server...

1. If you were on Unix/Linux,

   - uptime of the server : /usr/bin/uptime (in perl: @uptime = `/usr/bin/uptime`;)

   - uptime of apache : nothing available, but you can, in perl, do a "stat" of the PID file created when Apache is started.
      This way you get the date time when Apache was started:
      $mtime = (stat("/var/run/httpd.pid"))[9];
      $nicet   = localtime($mtime); # human readable date :)

2. If you were on Windows

    - try to see if there is a similar httpd.pid or apache.pid file created when started, so that you can apply the "uptime of apache" of case 1 above.

    - if none available, another way is to check for the last line of the (default) "error_log" file of apache:

       [Wed Apr 28 16:47:58 2004] [notice] Apache/2.0.1 (myOS) PHP/4.4.4 mod_ssl/3.3.3 OpenSSL/1.1.1 configured -- resuming normal operations

       And you just have to extract the leading date, e.g., $_ being the line,
        @_ = split /[\[\]]/;
        $nicet = $_[0];  # your date time is here
0
 
LVL 15

Expert Comment

by:periwinkle
Comment Utility
No comment has been added to this question in more than 21 days, so it is now classified as abandoned..
I will leave the following recommendation for this question in the Cleanup topic area:

    ACCEPT: Mercantilum

Any objections should be posted here in the next 4 days. After that time, the question will be closed.

Periwinkle
EE Cleanup Volunteer
0

Featured Post

Complete Microsoft Windows PC® & Mac Backup

Backup and recovery solutions to protect all your PCs & Mac– on-premises or in remote locations. Acronis backs up entire PC or Mac with patented reliable disk imaging technology and you will be able to restore workstations to a new, dissimilar hardware in minutes.

Join & Write a Comment

Introduction As you’re probably aware the HTTP protocol offers basic / weak authentication, which in combination with the relevant configuration on your web server, provides the ability to password protect all or part of your host.  If you were not…
If your site has a few sections that need to be secure when data is transmitted between the server and local computer, such as a /order/ section for ordering or /customer/ which contains customer data, etc it would of course be recommended to secure…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

7 Experts available now in Live!

Get 1:1 Help Now