Solved

Apache uptime to web page

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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Help with htaccess under apache 7 29
ProxyPass - Problem 5 184
Changing Sitemap Frequency on XML File 3 74
Increase number of concurrent connections in Apache tomcat 6 2 98
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.
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…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

839 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