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]
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
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
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
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
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
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 }'
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"
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
wainvmstator the process states intopbefore adding CPUs.Comparing load across machines without dividing by
nprocis meaningless: 8.0 is fine on 16 cores and a queue on 4.Do not parse
uptime's plain output in scripts: it says5 min,3:42or12 days, 3:42depending on how long the machine has been up. Read/proc/uptimeor useuptime -s.Inside a container,
uptimereports 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).
-pand-sare procps (Linux) options; macOS and the BSDs have a plainuptimeonly. On macOS,sysctl -n kern.boottimegives the boot time.There is no
/proc/loadavgon macOS;sysctl -n vm.loadavgprints the three averages.
Options worth knowing
A selection, described in our own words. For the full list, see uptime(1) or uptime --help.
| Option | What it does |
|---|---|
-p, --pretty | Print only how long the system has been up, in words. |
-s, --since | Print the date and time the system booted. |
-h, --help | Print usage and exit. |
-V, --version | Print the procps version and exit. |
Related
topShow a live, sorted view of processes and system load; batch mode prints snapshots for logs and scripts.freeShow how much RAM and swap is in use, free, and available to new programs.vmstatReport processes, memory, swap, I/O and CPU activity, once or at a regular interval.psPrint a snapshot of running processes, with the columns, filters and sort order you choose.datePrint the current date and time in any format, or convert and calculate dates.