uptimex
Tell how long the system has been running.
Mirrors GNU uptime. Run it as uptimex, or as gnux uptimex.
Synopsis
uptimex [OPTION]... [FILE]GNU reference
Description
uptimex prints, on one line, the current time, how long the system has been up, how many users are logged in, and the load averages: the average number of processes running or waiting to run over the last 1, 5 and 15 minutes (on Linux, processes waiting on disk count too). A load average above the number of CPUs (nprocx) means work is queuing. With FILE, the users and the boot time are read from that utmp file instead of the current records. The boot time comes from /proc on Linux, kern.boottime on macOS and FreeBSD, and the tick count on Windows, where the users are the signed-in sessions; Windows keeps no load average, so that part is left out there, as GNU uptime leaves it out wherever the system cannot report it. If the boot time cannot be found the time up is shown as '????' and the exit status is 1.
gnux's terminal view (BR-13): on a terminal, uptimex draws a panel titled with how long the system has been up, holding the time, the users, each load average as a bar of the load against the CPUs (yellow from 75% of them, red from 90%, full when work is queuing) and the CPU count. --pretty[=WHEN] and --theme=NAME, options of gnux's own, choose the view (GNUX_PRETTY, GNUX_THEME); piped or redirected output is GNU's line.
Permissions
Needs no permissions.
Use cases
- Checking whether a server rebooted unexpectedly.
- Seeing at a glance whether a machine is overloaded.
- Recording
uptimeand load in monitoring logs. - Comparing the load with the CPU count before starting a heavy job.
- Getting the same summary on Linux, macOS and Windows.
Flags
--help display this help and exit
--pretty WHEN[="always"] the gnux terminal view WHEN: 'always' (the default when WHEN is omitted), 'auto' (the default: on a terminal only), or 'never'; GNUX_PRETTY sets the default
--theme NAME color the view with the built-in theme NAME (gnux theme picks and saves one); GNUX_THEME sets the default
--version output version information and exitExamples
Check how long the machine has been up and how loaded it is
uptimex 14:03:22 up 3 days 3:19, 2 users, load average: 0.42, 0.37, 0.31A server feels slow: compare the load with the number of CPUs
uptimex && nprocx 10:12:40 up 41 days 2:07, 1 user, load average: 15.83, 14.90, 12.02
8Did the server reboot overnight? Check the time up
uptimex 07:58:01 up 2:11, 0 users, load average: 0.08, 0.05, 0.01Log the load every 5 minutes from cron
*/5 * * * * uptimex >> /var/log/load.logExtract just the 1-minute load average
uptimex | trx -s ' ' | cutx -d, -f4 | cutx -d: -f2 0.42Show the boot time itself rather than the time since
whox -b system boot Oct 9 10:44Read the users and boot time from a saved utmp file
uptimex /var/run/utmpWait until the load drops below 1 before starting a backup
until uptimex | grep -q 'load average: 0\.'; do sleepx 60; done; ./backup.shRecord the uptime in a status report
echox "$(hostnamex): $(uptimex)" >> status.txtCheck several machines' uptime over SSH
for h in web1 web2 db1; do ssh "$h" uptimex; doneShow the uptime in the portable gnux shell, the same on every OS
gnux shell -c 'uptimex && whox -q'Options
Each option has a page of its own, with its usage and examples.
- --pretty: The
gnuxterminal view WHEN: 'always' (the default when WHEN is omitted), 'auto' (the default: on a terminal only), or 'never'; GNUX_PRETTY sets the default. - --theme: Color the view with the built-in theme NAME (
gnuxtheme picks and saves one); GNUX_THEME sets the default.
Exit status
| Status | Meaning |
|---|---|
| 0 | success: every operand was processed |
| 1 | failure: an operand could not be processed (diagnosed on standard error), or a command-line mistake |
Help in the terminal
uptimex --help # options, first examples, exit status
gnux help uptimex # this page: the full manual
gnux help uptimex --OPTION # one option in depth, with its examples