Solved

Apache uptime to web page

Posted on 2004-04-30
3
437 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 10

Accepted Solution

by:
Mercantilum earned 125 total points
ID: 10961714
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
ID: 11761612
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

Enroll in June's Course of the Month

June's Course of the Month is now available! Every 10 seconds, a consumer gets hit with ransomware. Refresh your knowledge of ransomware best practices by enrolling in this month's complimentary course for Premium Members, Team Accounts, and Qualified Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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…
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.

728 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