Solved

Apache uptime to web page

Posted on 2004-04-30
3
433 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

Don't miss ATEN at NAB Show April 24-27!

Visit ATEN at NAB Show to learn how our "Seamlessly Entertaining" solutions deliver fast, precise video streaming without delays for the broadcasting and media environment. ATEN will showcase its 16x16 Modular Matrix Switch (VM1600) and KVM Over IP Solution (KE6900 series).

Question has a verified solution.

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

Suggested Solutions

As Wikipedia explains 'robots.txt' as -- the robot exclusion standard, also known as the Robots Exclusion Protocol or robots.txt protocol, is a convention to prevent cooperating web spiders and other web robots from accessing all or part of a websit…
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…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

726 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