>_cmd.script

uptime

Show how long the system has been running and load averages

System

By CMD Script Team · 3 min read · Last updated

SYNTAX
uptime [OPTIONS]

Options

Command options and flags
FlagDescription
-pPrint uptime in a friendly, pretty format, e.g. 'up 3 days, 2 hours, 15 minutes'
-sPrint the exact date and time the system was booted
-VPrint version information for the uptime/procps-ng package

Distribution compatibility

  • Ubuntu
  • Debian
  • Fedora
  • Arch
  • macOS (BSD uptime, no -p/-s flags)

What it does

uptime prints a single summary line: the current time, how long the system has been running since its last boot, the number of currently logged-in users, and the load average over the last 1, 5, and 15 minutes. It's usually the very first command admins run to get a quick pulse-check on a server's health and workload.

Beginner examples

  • uptime — print the standard summary line
  • uptime -p — print a human-friendly duration like up 2 weeks, 3 days, 4 hours, 12 minutes
  • uptime -s — print the exact date/time the machine booted
uptime

Advanced examples

  • Extract just the load averages for a monitoring script: uptime | awk -F'load average:' '{print $2}'
  • Calculate exact uptime duration from boot timestamp: uptime -s
  • Alert when 1-minute load average crosses a threshold in a cron job or health check script by parsing uptime's output.
  • Watch load trend in real time: watch -n 5 uptime
  • Combine with nproc to judge whether load average indicates saturation: echo "cores: $(nproc), load: $(uptime | awk -F'load average:' '{print $2}')"
watch -n 5 uptime

Common mistakes

  • Reading a load average of, say, 4.00 as automatically "bad" without checking the number of CPU cores — load average is only meaningful relative to nproc.
  • Confusing "uptime" (how long the machine has been running) with "how long a specific service has been running" — use systemctl status <service> for the latter.
  • Assuming the three load numbers are CPU percentages — they're not percentages, they're averages of the run-queue length over time windows.
  • Forgetting that on heavily virtualized or containerized hosts, load average can behave unexpectedly since it reflects the host's view, not necessarily the container's limits.

Tips

  • A quick sanity rule: if 1-minute load average is consistently higher than your core count, the system is likely CPU-bound.
  • uptime -p is friendlier for scripts that display status to humans (dashboards, Slack bots) than the raw default format.
  • Many monitoring tools (Nagios, Zabbix) parse uptime's output directly for lightweight load checks when a full metrics agent isn't available.

Best practices

  • Compare load average against nproc (core count) rather than treating it as an absolute number — a load of 8 is fine on a 16-core box but concerning on a 2-core one.
  • Use uptime -s instead of subtracting date from a parsed duration string when you need an exact, reliable boot timestamp for scripting.
  • Pair uptime with top or vmstat when load average looks high — uptime tells you that something's busy, not what.

Try it yourself

A simulated shell with a sample home directory — experiment freely, nothing leaves your browser. Type help to list supported commands.

Real-world use cases

  • First command run during an incident to check if a server is under heavy load.
  • Confirming a server rebooted (and roughly when) after a patch or crash.
  • Lightweight health checks in cron jobs or shell-based monitoring scripts.
  • Quickly verifying multiple users are logged into a shared server before a maintenance window.

Common interview questions

  • What do the three numbers in uptime's load average mean? The average number of processes wanting CPU time, over the last 1, 5, and 15 minutes respectively.
  • Is a load average of 4 always bad? No — it depends on the number of CPU cores; a load of 4 on an 8-core machine is fine, but concerning on a single-core machine.
  • How would you get the exact system boot time from uptime? uptime -s, which prints the boot timestamp directly rather than an elapsed duration.

Frequently Asked Questions

What do the three load average numbers mean?

They represent the average number of processes waiting for or using the CPU over the last 1, 5, and 15 minutes respectively. A number close to or above your CPU core count sustained over time suggests the system is CPU-saturated.

How is uptime different from w?

uptime shows only the system-level summary (current time, how long it's been running, number of logged-in users, and load averages) as its final line; w shows that same summary plus a full per-user table of who is logged in and what they're running.

How can I get just the boot time instead of elapsed time?

Use uptime -s, which prints the exact timestamp the system booted, e.g. 2026-07-01 09:14:03 — handy for scripting or calculating exact uptime duration.

Cheat sheet

Download a quick-reference cheat sheet for uptime.