It’s simple. But most of the admins are not aware about these commands.
We can check the uptime status of Apache service by different ways. Here I’m explaining some of them with examples.
As we know about Apache, it’s a commonly using web-server for Linux server. It’s completely open source and easy to customize.
Several online UPTIME monitoring tools are available now-a-days. We already discussed about some top most tools on this topic >> Top website or server uptime or downtime online monitoring tools << Please go through this post if you are planning to monitor your website using some online tools.
We can check the Apache uptime from the “fullstatus” itself. Please log into the server as root and execute the following command:
1. SSH as root.
httpd fullstatus|grep -i uptime
Try “apachectl” too instead of httpd…
[~]# httpd fullstatus|grep -i uptime Server uptime: 13 days 3 hours 47 minutes 23 seconds
It’s simple!! The server uptime can be checked from the command “uptime.”
Another way, it’s from the command PS. It’s process level.
The command PS on the server report a snapshot of the current processes running on the server. So, definitely, the PS can tell us something about the Apache service’s start up time. Here the trick goes!
We can use the following options with PS command, comm, etime and user. The “comm” parameter displays command executing, “etime” shows total time elapsed that command and the “user” filed tell us about the users involved with that command or processes. Here we goes with the following command:
ps -eo comm,etime,user | grep httpd
In the above, grep out the process started by ROOT user. For that, use the following command:
ps -eo comm,etime,user | grep httpd | grep root
See the sample output
[~]# ps -eo comm,etime,user | grep httpd|grep root httpd 26-13:14:41 root
Which means 26 days, 13 hours, 14 minutes and 41 seconds 🙂
After a restart, the results became as follows:
# ps -eo comm,etime,user | grep httpd|grep root httpd 00:37 root
# httpd fullstatus|grep -i uptime Server uptime: 33 seconds
That’s it!! Go ahead 🙂