Example 1
Display Basic System Uptime
$ uptime
14:23:45 up 5 days, 3:21, 2 users, load average: 0.52, 0.48, 0.41
Displays comprehensive system status including current time, how long the system has been running, number of logged-in users, and load averages for the last 1, 5, and 15 minutes. This is the most common form of the uptime command and provides a quick overview of system health and stability.
Reading: Current time is 14:23:45, system up for 5 days and 3 hours 21 minutes, 2 users logged in, load averages are 0.52, 0.48, 0.41
Example 2
Display Uptime Since Boot
$ uptime -s
2025-10-13 11:02:34
Shows the date and time when the system was last booted using the '-s' (since) option. Displays in YYYY-MM-DD HH:MM:SS format. Useful for determining when the last reboot occurred, tracking system restarts, or verifying maintenance windows.
Maintenance Tracking: Essential for verifying patch installation reboots or unplanned restarts
Example 3
Display Pretty Uptime Format
$ uptime -p
up 5 days, 3 hours, 21 minutes
Shows uptime in a human-readable, pretty format using the '-p' option. Omits current time, user count, and load averages, focusing only on how long the system has been running. Easier to read than the standard format, perfect for casual monitoring or reporting.
Readability: Best format for quick visual checks or non-technical users
Example 4
Understanding Load Averages
$ uptime
14:23:45 up 5 days, 3:21, 2 users, load average: 2.50, 1.80, 1.20
Load averages represent the average number of processes in a runnable or uninterruptible state over 1, 5, and 15 minute intervals. On a single-CPU system, 1.00 means 100% utilized. On a 4-CPU system, 4.00 means 100% utilized. These numbers help identify if the system is under-loaded, properly loaded, or overloaded.
Interpretation: 2.50, 1.80, 1.20 shows load decreasing over time. On a 4-core system, this is moderate load (62%, 45%, 30% utilized)
Example 5
Monitor Uptime Continuously
$ watch -n 1 uptime
Every 1.0s: uptime hostname: Sat Oct 18 14:23:45 2025
14:23:45 up 5 days, 3:21, 2 users, load average: 0.52, 0.48, 0.41
Continuously monitors uptime by combining with the watch command. Updates every second (or specified interval) to track load average changes in real-time. Excellent for monitoring system behavior during performance testing, troubleshooting load spikes, or observing system under stress.
Real-Time Monitoring: Press Ctrl+C to stop. Adjust interval with -n option (e.g., watch -n 5 uptime)
Example 6
Calculate CPU Core Count and Load Ratio
$ echo "CPUs: $(nproc)"
$ uptime | awk '{print "Load: " $(NF-2) " " $(NF-1) " " $NF}'
$ echo "Load per CPU: $(uptime | awk -v cpus=$(nproc) '{gsub(/,/,"",$10); printf "%.2f", $10/cpus}')"
CPUs: 4
Load: 0.52, 0.48, 0.41
Load per CPU: 0.13
Calculates load average per CPU core to determine actual system utilization percentage. Dividing load average by CPU count gives a normalized value: less than 1.0 means under-utilized, around 1.0 is fully utilized, greater than 1.0 means processes are waiting. Essential for proper load interpretation on multi-core systems.
Analysis: 0.13 per CPU means only 13% utilization - system has plenty of capacity
Example 7
Log Uptime to File
$ uptime >> /var/log/uptime.log
$ date >> /var/log/uptime.log
$ tail /var/log/uptime.log
14:23:45 up 5 days, 3:21, 2 users, load average: 0.52, 0.48, 0.41
Sat Oct 18 14:23:45 EDT 2025
Appends uptime information to a log file for historical tracking. Combined with cron, this creates a time-series database of system load. Useful for capacity planning, identifying usage patterns, or troubleshooting intermittent performance issues by correlating with specific times.
Automation: Add to crontab: */5 * * * * uptime >> /var/log/uptime.log (logs every 5 minutes)
Example 8
Check if System Needs Reboot
$ uptime -s
$ last reboot | head -1
2025-10-13 11:02:34
reboot system boot 5.15.0-89-generi Fri Oct 13 11:02 still running
Combines uptime with the last reboot command to verify the last system restart. Useful after applying kernel updates that require reboot, or checking if a server has been restarted as part of maintenance. Compare uptime with expected reboot times to verify maintenance compliance.
Kernel Updates: After kernel updates, verify new kernel is running with uname -r
Example 9
Alert on High Load Average
#!/bin/bash
# Alert if 1-min load average exceeds CPU count
CPUS=$(nproc)
LOAD=$(uptime | awk '{gsub(/,/,"",$10); print $10}')
if (( $(echo "$LOAD > $CPUS" | bc -l) )); then
echo "HIGH LOAD ALERT: $LOAD on $CPUS CPUs" | mail -s "Server Load Alert" admin@example.com
fi
# If load is 5.2 on 4-CPU system:
HIGH LOAD ALERT: 5.2 on 4 CPUs
Creates a monitoring script that alerts when load average exceeds CPU capacity. Extracts the 1-minute load average, compares it to CPU count, and sends email if threshold exceeded. Add to cron for continuous monitoring. Essential for proactive system administration and preventing performance degradation.
Monitoring: Adjust threshold as needed (e.g., $CPUS * 0.8 for 80% threshold)
Example 10
Format Uptime for Dashboard Display
$ uptime -p | sed 's/up //' | sed 's/, /\n/g'
5 days
3 hours
21 minutes
$ printf "System: %s\nUptime: %s\nLoad: %s\n" \
"$(hostname)" \
"$(uptime -p | sed 's/up //')" \
"$(uptime | awk -F'load average:' '{print $2}' | xargs)"
System: webserver01
Uptime: 5 days, 3 hours, 21 minutes
Load: 0.52, 0.48, 0.41
Formats uptime output for dashboards, monitoring systems, or status pages. Extracts and restructures information for better presentation. Useful for creating custom monitoring displays, status reports, or integrating with monitoring tools like Grafana, Nagios, or custom web dashboards.
Integration: Output can be parsed by monitoring tools or displayed in web interfaces
Bonus
Load Average Interpretation Guide
Understanding Load Averages:
============================
What They Mean:
- Load average = average number of processes in runnable/waiting state
- Three numbers = 1-minute, 5-minute, 15-minute averages
- Includes processes waiting for CPU and uninterruptible I/O
Interpreting Values (per CPU core):
0.00 - 0.70 Optimal - System has spare capacity
0.70 - 1.00 Good - System properly utilized
1.00 - 1.50 Acceptable - Monitor for trends
1.50 - 2.00 Concerning - Investigate cause
2.00+ Critical - Immediate attention needed
Example Interpretations:
Single CPU System:
0.50, 0.48, 0.41 ✓ Light load, plenty of capacity
1.00, 0.95, 0.90 ✓ Fully utilized but not overloaded
2.50, 2.20, 2.00 ✗ Processes waiting, system stressed
4-CPU System:
2.00, 1.80, 1.60 ✓ 50% utilized (2.00 / 4 = 0.50)
4.00, 3.80, 3.60 ✓ Fully utilized but healthy
8.00, 7.50, 7.00 ✗ Overloaded - investigate
Trend Analysis:
0.50, 1.00, 1.50 ↗ Load increasing - monitor closely
1.50, 1.00, 0.50 ↘ Load decreasing - issue resolving
2.00, 2.00, 2.00 → Sustained high load - action needed
0.50, 0.50, 0.50 → Stable low load - healthy
Common Causes of High Load:
- CPU-intensive processes (compilation, encoding)
- Insufficient CPU resources for workload
- Disk I/O bottleneck (slow drives)
- Memory pressure causing swapping
- Network I/O waiting
- Too many concurrent processes
Investigation Commands:
top See which processes consuming CPU
iostat Check disk I/O performance
vmstat Check memory and swap usage
ps aux --sort=-pcpu | head Top CPU consumers
iotop Monitor I/O by process
Quick Health Check:
CPUS=$(nproc)
LOAD=$(uptime | awk '{gsub(/,/,"",$10); print $10}')
RATIO=$(echo "scale=2; $LOAD / $CPUS" | bc)
if (( $(echo "$RATIO < 0.7" | bc -l) )); then
echo "✓ System healthy (load ratio: $RATIO)"
elif (( $(echo "$RATIO < 1.0" | bc -l) )); then
echo "⚠ System busy (load ratio: $RATIO)"
else
echo "✗ System overloaded (load ratio: $RATIO)"
fi
Comprehensive guide to understanding and interpreting load averages, including thresholds, trend analysis, common causes, and investigation techniques.
Reference
uptime Command Quick Reference
Basic Usage:
uptime Display standard uptime info
uptime -s Show boot time (since)
uptime -p Pretty format (human-readable)
uptime -h Display help
uptime -V Display version
Output Format:
Standard output contains:
- Current time
- System uptime
- Number of logged-in users
- Load averages (1, 5, 15 minutes)
Related Commands:
w Detailed user and uptime info
top Real-time system monitoring
last reboot Show reboot history
who Show logged-in users
nproc Display CPU core count
cat /proc/uptime Raw uptime in seconds
Monitoring Patterns:
# Continuous monitoring
watch -n 5 uptime
# Log periodically (cron)
*/10 * * * * uptime >> /var/log/uptime.log
# Check load ratio
echo "scale=2; $(uptime | awk '{gsub(/,/,"",$10); print $10}') / $(nproc)" | bc
# Alert on high load
[ $(uptime | awk '{gsub(/,/,"",$10); print int($10)}') -gt $(nproc) ] && echo "High load!"
# Format for parsing
uptime | awk -F'load average:' '{print $2}' | tr -d ' '
Script Examples:
# Get individual load values
LOAD1=$(uptime | awk -F'load average:' '{print $2}' | cut -d',' -f1 | xargs)
LOAD5=$(uptime | awk -F'load average:' '{print $2}' | cut -d',' -f2 | xargs)
LOAD15=$(uptime | awk -F'load average:' '{print $2}' | cut -d',' -f3 | xargs)
# Calculate uptime in days
uptime -p | grep -oP '\d+(?= days?)' || echo "0"
# Check if uptime > 30 days (needs reboot)
DAYS=$(uptime -p | grep -oP '\d+(?= days?)' || echo "0")
[ $DAYS -gt 30 ] && echo "Consider rebooting for updates"
Complete reference for uptime command including options, output interpretation, monitoring patterns, and practical scripting examples.