How to Check Server Uptime with Common Commands

Introduction

What is server uptime?

  • Server uptime refers to the amount of time a server has been continuously running without any downtime or restarts.
  • Knowing your server's uptime helps monitor its stability and performance, ensuring it’s available for your services and users.

Why is uptime important?

  • Frequent downtimes can indicate server instability, resource exhaustion, or system crashes, impacting your business operations.
  • Monitoring uptime helps with troubleshooting, system maintenance, and performance optimization.

Common Server Uptime Commands

1. uptime Command (Linux/Unix)

The uptime command is the simplest way to check how long a Linux/Unix server has been running.

uptime

Output:

Displays the current time, how long the system has been running, the number of users, and system load averages for the last 1, 5, and 15 minutes.

12:42  up 27 days,  3:10, 3 users, load averages: 6.54 7.87 13.66

2. w Command (Linux/Unix)

w command not only shows uptime but also lists logged-in users and their activity.

w

Output:

Includes the system uptime, the number of users, and what each user is doing.

3. top Command (Linux/Unix)

The top command is primarily used to monitor processes but includes uptime as well.

top

Output:

Uptime is shown at the top of the screen along with system load and resource usage.

4. systeminfo Command (Windows)

In Windows servers, systeminfo gives detailed information about the system, including uptime.

systeminfo | find "System Boot Time"

Output:

Shows the last boot time, which you can calculate to get the uptime.

5. net stats Workstation Command (Windows)

Use net stats to check when the Workstation service statistics started.

net stats workstation | find "Statistics since"

Output:

Shows when statistics collection started for the Workstation service. The service can restart independently of Windows, so use the PowerShell command below to check OS uptime.

Get Windows Server uptime with PowerShell

Run this in PowerShell on the Windows server to get the time since its last boot:

(Get-Date) - (Get-CimInstance Win32_OperatingSystem).LastBootUpTime

The command returns a TimeSpan with days, hours, minutes, and seconds. To get just the last boot timestamp, run:

(Get-CimInstance Win32_OperatingSystem).LastBootUpTime

Microsoft documents LastBootUpTime as the time the operating system last restarted. OS uptime tells you how long Windows has been running; check a public website or API with Ping Now's URL checker to see whether it responds from outside the server.

Why Checking Uptime is Useful

  • System Stability Monitoring: Regularly checking uptime helps ensure your server is performing as expected.
  • Maintenance Scheduling: Uptime data is crucial when scheduling system updates, maintenance, or backups.
  • Troubleshooting: If a server is frequently rebooting, this could point to hardware or software issues that need attention.
  • SLAs and Availability: For service providers, maintaining high uptime is critical to meeting SLAs (Service Level Agreements).

Additional Tools to Monitor Uptime

Third-party tools:

  • There are dedicated monitoring tools like Nagios, Zabbix, and Pingdom that can automate uptime monitoring, alerting you of any downtimes or issues.

Cloud Providers:

  • Cloud platforms like AWS, Azure, and GCP often provide built-in monitoring tools (e.g., AWS CloudWatch) to keep track of uptime for cloud-based servers.

This tools are often comprehensive, provides a lot of customization and requires maintenance to keep them up and running.

For most use-cases, monitoring whether your website or web service API is up is the end goal. For such cases, tools like Ping Now is both easy to use, effective and cost-efficient.

Conclusion

  • Regularly checking server uptime with the right commands and tools ensures that your servers are running smoothly and any potential issues can be caught early.
  • Whether you're using Linux, Unix, or Windows, the uptime commands provide quick insights into your server's health and stability.
  • For ease-of-use and effective monitoring, adopt tools like Ping Now
by @hboon

fb483d48a83e6ffe32eb15dae653a8b12de75f77