Overview of uptime
`uptime` command shows the continuous running time of the system from the last restart to the present. This serves as an important indicator of the server's stability and availability. Additionally, it allows you to gauge how efficiently the current CPU resources are being utilized through the average load of the system.
Key Roles of uptime
`uptime` command is primarily used for the following purposes:
Main Use Cases
- Check System Stability: Evaluate stability by checking how long the system has been running without a restart.
- Performance Diagnosis: Indirectly assess how free or scarce the current system resources are through the average load.
- Check Number of Users: Check the number of users currently logged into the system.
- Shell Scripts: Can be utilized in scripts that periodically check the system status.
Interpreting Output: Load Average
One of the most important parts of the `uptime` output is the 'load average'. This value represents the amount of work the system has to process (i.e., the number of processes waiting in the execution queue) over time. Three numbers are displayed, representing the average load over the last 1, 5, and 15 minutes.
Interpreting Load Average
- Load Average: Each number represents the average load of the system over a specific time. For example, `0.50, 0.70, 0.80` indicates the average load over the last 1, 5, and 15 minutes, respectively.
- Comparison with 'CPU Core Count': Generally, the load average value is interpreted in relation to the number of CPU cores in the system. For example, a load average of `4.00` on a 4-core CPU system means the CPU is fully utilized and there are many pending tasks. A value below `1.00` indicates a level that is relaxed or sufficiently manageable on a single core. If the value is lower than the number of CPU cores, it indicates availability, while a higher value may indicate overload.
Key uptime Command Options
`uptime` command is used without options by default, but a few simple options can be used to modify the output format.
1. Specify Output Format
Generated command:
Try combining the commands.
Description:
`uptime` Executes the command.
Combine the above options to virtually execute commands with AI.
Usage Examples
Learn how to effectively check system uptime and load status through various usage examples of the `uptime` command.
Check Basic Uptime Information of Current System
uptime
The most basic execution of the `uptime` command shows how long the system has been up, how many users are logged in, and the average load.
Check System Uptime Concisely
uptime -p
Outputs only the time since the system was booted in a human-readable format like 'up 1 day, 5 hours'.
Check Exact Date and Time of System Boot
uptime -s
Outputs the exact moment the system was last restarted in the format YYYY-MM-DD HH:MM:SS.
Extract Load Average from uptime Result
uptime | awk '{print $NF}'
Uses the `awk` command to extract only the load average value from the `uptime` output. Useful in scripts for monitoring system load.
Extract Only 1-Minute Load Average
uptime | grep -oP 'load average: \K\d+\.\d+' | head -n 1
Uses a pipeline to accurately extract only the average load for the last minute from `uptime` output. Utilized in performance monitoring scripts.