uptime - macOS
Overview
The uptime
command provides information about the uptime of the macOS system. It displays the amount of time that the computer has been running continuously since its last boot.
Syntax
uptime [options]
Options/Flags
- -s: Display the uptime in seconds instead of the default human-readable format.
- -p: Display the uptime in a portable format suitable for scripts or other programs.
Examples
Simple usage:
uptime
Output:
10:23 up 1 day, 5:23, 3 users, load averages: 0.37 0.46 0.42
Display uptime in seconds:
uptime -s
Output:
89819
Display uptime in portable format:
uptime -p
Output:
1 day 5 hours 23 minutes
Common Issues
Incorrect uptime value: If the displayed uptime appears incorrect, it may be due to a system restart or a problem with the system clock. Check the system logs or use the systemsetup
command to verify the system time.
Integration
The uptime
command can be used in conjunction with other commands to gather additional system information. For example:
uptime && date
Output:
10:23 up 1 day, 5:23, 3 users, load averages: 0.37 0.46 0.42
Sat Feb 11 15:23:05 PST 2023
Related Commands
who
: Displays information about logged-in users.top
: Displays a real-time view of the running processes.ps
: Displays a snapshot of the running processes at a specific point in time.