A practical reference for sysadmins using uptime to monitor load averages, detect unexpected reboots, and identify DoS or cryptominer attack signatures.
What is uptime?
The uptime command outputs four pieces of information: the current time, how long the system has been running since its last boot, the number of currently logged-in users, and the system load averages for the last 1, 5, and 15 minutes. While seemingly simple, these metrics carry significant security signal. An unexpected low uptime indicates a recent reboot — potentially caused by a kernel exploit, a rootkit installation requiring a reboot, or unauthorized server access. Load averages above the number of CPU cores during off-peak hours indicate sustained CPU saturation, which is the primary signature of cryptomining malware. The three load average values together also indicate trend direction: if the 1-minute average is much higher than the 15-minute average, load is increasing. If the reverse is true, an incident may be subsiding. For sysadmins, uptime is the fastest possible system health check — a single command that runs in milliseconds and provides immediate context before deeper investigation.
Syntax
uptime
uptime -p
uptime -s
cat /proc/uptimeThe default uptime output is a single line. Use -p for human-readable uptime duration (e.g. ‘up 3 days, 4 hours’). Use -s to get the exact date and time the system was last booted — useful for correlating a suspected reboot with access logs. /proc/uptime provides the raw uptime in seconds for scripting.
Key Options and Flags
| Flag / Parameter | Description | Security Note |
|---|---|---|
(no flags) | Display current time, uptime duration, user count, and 1/5/15-minute load averages | The most useful default output — check load averages against your CPU core count immediately |
-p | Show uptime in human-readable format: 'up X days, Y hours, Z minutes' | — |
-s | Show the exact date and time the system was last booted | Cross-reference with auth logs to determine who was logged in or what ran at boot time |
/proc/uptime | Raw file: first field is uptime in seconds, second is idle CPU time in seconds | Use in scripts to calculate exact uptime or detect reboots programmatically |
Common Use Cases
Detect Unexpected Reboots Indicating Unauthorized Access
A server that has been running for months should have a correspondingly high uptime value. A low uptime on a production server — especially one not scheduled for maintenance — is an immediate red flag. Use uptime -s to get the exact reboot time, then correlate with authentication logs to determine who had access or what ran at boot.
uptime -s
# Then check who logged in around that time:
last | head -20Use Load Averages as an Early Cryptominer Warning
Cryptominers consume sustained CPU and produce load averages that remain persistently above the CPU core count, often without a clear legitimate explanation. Compare the 1-minute and 15-minute averages: a sustained elevation across all three intervals points to a persistent process, not a temporary spike. Follow up immediately with ps aux --sort=-%cpu | head -10 to identify the offending process.
uptime
# If load > CPU cores, immediately run:
ps aux --sort=-%cpu | head -10Correlate Uptime with Cron Schedule to Detect Timed Attacks
Some malware executes on a schedule via cron, causing load spikes at predictable intervals. By monitoring uptime output over time and comparing spike timing against known cron schedules, you can detect scheduled malicious tasks before finding the crontab entry itself.
# Log load averages every minute to detect patterns
while true; do echo "$(date): $(uptime)"; sleep 60; done >> /var/log/load_monitor.logSecurity Relevance: Load Averages as an Early DoS and Cryptominer Signal
The load average is one of the most reliable passive security indicators available without any additional tooling. Two threat patterns produce distinctive load signatures: DoS attacks cause a rapid, often asymmetric spike in the 1-minute average that may not yet appear in the 15-minute value; cryptominers cause a sustained, flat elevation across all three intervals because their CPU usage is continuous rather than bursty. An unexpected reboot visible through a low uptime value is equally significant. Reboots on production servers are planned events. An unplanned reboot may indicate a kernel panic caused by an exploit, a rootkit installation that requires a reboot to activate its kernel module, a hardware fault, or unauthorized access by someone with physical or out-of-band console access. In all cases, the correct response is to immediately audit authentication logs, running processes, and recently modified files. The uptime -s value gives you the exact timestamp to anchor that investigation.
- Load average consistently above the number of CPU cores during off-peak hours is the primary cryptominer load signature
- An unexpectedly low uptime on a production server should be treated as a security incident until proven otherwise
- A high 1-minute load average with a normal 15-minute average indicates a very recent spike — investigate immediately before it subsides
- Uptime alone cannot distinguish between a legitimate reboot and a malicious one — always cross-reference with boot logs and auth logs
Practical Examples
Check current load averages and compare against CPU core count
uptime && nprocRunning uptime immediately followed by nproc gives you the load averages and the number of CPU cores in two lines. If any load average exceeds the core count, the system is saturated.
Get the exact boot time to anchor a reboot investigation
uptime -sOutputs the date and time of the last system boot in YYYY-MM-DD HH:MM:SS format. Use this timestamp to query auth logs, syslog, and kernel logs for events at and immediately after the reboot.
Log load averages continuously to detect timed attack patterns
while true; do echo "$(date '+%Y-%m-%d %H:%M:%S'): $(uptime)"; sleep 60; done >> /var/log/load_monitor.logCreates a rolling log of load averages with timestamps. Running this in a screen or tmux session during an investigation reveals whether high load is continuous or periodic, which distinguishes a background process from a scheduled task.
Troubleshooting Common Issues
Problem: Load average is high but no single process shows high CPU in ps aux
Solution: High load without a visible CPU-intensive process often indicates I/O wait rather than CPU saturation. Run iostat -x 1 5 to check disk I/O. Load average counts both CPU-bound and I/O-blocked processes — a slow disk or a failing drive can cause load to spike without corresponding CPU usage.
Problem: uptime shows a recent reboot but no reboot was scheduled
Solution: Check last reboot to see the reboot history from wtmp. Then review journalctl -b -1 (previous boot) for the final log entries before shutdown — kernel panics, OOM killer events, and forced shutdowns all leave distinctive log entries that help determine whether the reboot was caused by a fault, an exploit, or a manual action.
Problem: Need uptime data in a script without parsing the human-readable output
Solution: Read /proc/uptime directly. The first field is the number of seconds since boot as a float. Divide by 86400 for days, 3600 for hours. This is more reliable than parsing the text output of uptime which varies in format across distributions.
Summary
The uptime command is the fastest possible system health check — one line of output that contains immediate security signal. Load averages above the CPU core count indicate saturation that warrants investigation. An unexpectedly low uptime indicates an unplanned reboot that should be treated as a security event. Use uptime -s to anchor any reboot investigation with an exact timestamp.
- Compare load averages against
nprocoutput — sustained load above core count during off-peak hours is the cryptominer signature - Run
uptime -simmediately when investigating an unexpected reboot to get the exact timestamp for log correlation - Periodic load spikes at consistent intervals suggest a cron-based malicious task — log load averages over time to identify the pattern
Related Commands
top for real-time process monitoring • htop for interactive process tree inspection • journalctl for systemd audit log queries
Is Your Linux Server Monitored 24/7?
INTRAM provides managed Linux hosting with continuous process and performance monitoring. We detect anomalies before they become incidents — so your team can focus on building, not firefighting.
Explore Managed Hosting