Linux Uptime Command With Usage Examples
The Linux Operating System is filled with several commands which any aspiring Linux expert or power user e.g. system admin must have a good grasp of. One of such commands is
uptime and today, I’ll briefly discuss its purpose and syntax.
Uptime is a command that returns information about how long your system has been running together with the current time, number of users with running sessions, and the system load averages for the past 1, 5, and 15 minutes. It can also filter the information displayed at once depending on your specified options.
uptime uses a simple syntax:
# uptime [option]
You can run the uptime command without any options like so:
It will display an output similar to:
09:10:18 up 106 days, 32 min, 2 users, load average: 0.22, 0.41, 0.32
In order of appearance, the command displays the
current time as the 1st entry,
up means that the system is running and it is displayed next to the total time for which the system has been running, the
user count (number of logged on users), and lastly, the system load averages.
What are system load averages? It is the average number of processes that are in a runnable or uninterruptable state. A process is in a runnable state when it is using the CPU or waiting to use the CPU; while a process is in an uninterruptable state when it is waiting for I/O access like waiting for a disk.
To know more about uptime, check out our article: Understand Linux Load Averages and Monitor Performance of Linux
Now let’s see some useful uptime command usage with examples.
Check Linux Server Uptime
You can filter uptime’s result to show only the running time of the system with the command:
# uptime -p up 58 minutes
Check Linux Server Starting Time
-s will display the date/time since when the system has been running.
# uptime -s 2019-05-31 11:49:17
Uptime Version & Help
As it is with most command line apps, you can display uptime’s version information and quick help page with the following command.
# uptime -h Usage: uptime [options] Options: -p, --pretty show uptime in pretty format -h, --help display this help and exit -s, --since system up since -V, --version output version information and exit For more details see uptime(1).
Having gotten to this point in the article, you can now use uptime for your daily runs and you’ll determine its level of usefulness to you. If you have any doubts, here’s its man page.