Solved

Apache uptime to web page

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

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

Question has a verified solution.

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

Hi, in this article I'm going to teach you how to run your own site, and how to let people in (without IP). I'll talk about and explain each step... :) By the way, everything in this Tutorial is completely free and legal. This article is for …
If you are a web developer, you would be aware of the <iframe> tag in HTML. The <iframe> stands for inline frame and is used to embed another document within the current HTML document. The embedded document could be even another website.
In this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …

628 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