opscape

System and users

uptime

Show how long the system has been running, how many users are logged in, and the load averages.

uptime [-p] [-s]

7 of 7 examples run in Debian 13.7 on 2026-10-31 · procps 2:4.0.4-9 · manual: uptime(1)

uptime prints one line: the current time, how long since the kernel booted, the number of logged-in sessions, and the load averages over the last 1, 5 and 15 minutes. It is the quickest "is this box struggling?" check there is, and the same line appears at the top of top and w.

A load average is the average number of tasks that were either running on a CPU or waiting for one (on Linux, also tasks stuck in uninterruptible I/O wait). It only means something next to the number of CPUs: a load of 4 is idle on a 32-core server and saturated on a 2-core VM. Read the three numbers as a trend: 1-minute higher than 15-minute means load is rising.

Everything uptime shows comes from /proc/uptime and /proc/loadavg, which scripts can read directly. The examples here run in a container, which shares the kernel of the machine it runs on, so the boot time and load are the host's.

Examples

Show uptime and load at a glance

uptime
explain
output
 20:21:44 up 67 days,  1:40,  0 users,  load average: 29.34, 45.26, 32.21

Current time, time since boot, logged-in sessions, then the 1, 5 and 15-minute load averages. The container has no login sessions, hence 0 users.

Print only the running time, in words

uptime -p
explain
output
up 9 weeks, 4 days, 1 hour, 40 minutes

-p (pretty) drops everything but the duration, spelled out in weeks, days, hours and minutes.

Show when the system booted

uptime -s
explain
output
2026-08-25 18:41:09

-s prints the boot time as YYYY-MM-DD HH:MM:SS in the local time zone (UTC here), a format that date -d can parse back if you need arithmetic on it.

Read the load averages straight from the kernel

cat /proc/loadavg
explain
output
29.34 45.26 32.21 31/9281 3826

The first three fields are the load averages. The fourth is runnable tasks over total tasks, and the last is the most recently assigned process ID. Parsing this file is more robust than cutting up uptime's output, whose wording changes with the uptime and the locale.

Get the uptime in seconds for a script

cut -d' ' -f1 /proc/uptime
explain
output
5794835.26

The first field of /proc/uptime is seconds since boot, with hundredths. (The second is the summed idle time of all CPUs, which can exceed the first on a multi-core machine.)

Compare the 1-minute load with the number of CPUs

read one five fifteen rest < /proc/loadavg
cpus=$(nproc)
echo "load $one on $cpus CPUs"
awk -v l="$one" -v c="$cpus" 'BEGIN { printf "%.2f per CPU\n", l / c }'
output
load 29.34 on 48 CPUs
0.61 per CPU

Dividing by the CPU count makes the number comparable across machines: around 1.0 per CPU means every core is busy, well under that means spare capacity. Bash arithmetic is integer only, so awk does the division.

Convert the uptime to whole days and hours

s=$(cut -d. -f1 /proc/uptime)
echo "up $(( s / 86400 )) days, $(( s % 86400 / 3600 )) hours"
output
up 67 days, 1 hours

cut -d. -f1 keeps the integer seconds so bash can do the arithmetic. This gives stable, script-friendly output where uptime -p would switch units as the number grows.

Common pitfalls

  • A high load average does not always mean CPU shortage. On Linux, processes blocked on slow disks or a hung NFS mount count too, so check wa in vmstat or the process states in top before adding CPUs.

  • Comparing load across machines without dividing by nproc is meaningless: 8.0 is fine on 16 cores and a queue on 4.

  • Do not parse uptime's plain output in scripts: it says 5 min, 3:42 or 12 days, 3:42 depending on how long the machine has been up. Read /proc/uptime or use uptime -s.

  • Inside a container, uptime reports the host's boot time and load, not the container's start time or its own share of the CPU.

GNU vs BSD and macOS

The examples above ran the GNU/Linux version. These are the differences that matter on macOS and the BSDs (written from their documentation, not run here).

  • -p and -s are procps (Linux) options; macOS and the BSDs have a plain uptime only. On macOS, sysctl -n kern.boottime gives the boot time.

  • There is no /proc/loadavg on macOS; sysctl -n vm.loadavg prints the three averages.

Options worth knowing

A selection, described in our own words. For the full list, see uptime(1) or uptime --help.

OptionWhat it does
-p, --prettyPrint only how long the system has been up, in words.
-s, --sincePrint the date and time the system booted.
-h, --helpPrint usage and exit.
-V, --versionPrint the procps version and exit.

Related