Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

/proc/uptime in Mac OS X

Tags:

macos

uptime

I need the EXACT same output as Linux's "cat /proc/uptime".

For example, with /proc/uptime, you'd get

1884371.64 38646169.12

but with any Mac alternative, like "uptime", you'd get

20:25 up 20:26, 6 users, load averages: 3.19 2.82 2.76

I need it to be exactly like cat /proc/uptime, but on Mac OS X.

like image 761
Ryan Avatar asked Mar 11 '13 00:03

Ryan


People also ask

Can you check uptime on a Mac?

Your Mac system displays its uptime in the System Information window. Click the Apple menu icon on the bar at the top of your screen, hold down the Option key, and click System Information. Scroll down in the left pane, select Software, and look for “Time since boot” to see your Mac's uptime.

Does macOS have a proc directory?

There are no /proc in macOS, however I want to get infomation about my system such as: /proc/loadavg. /proc/cpuinfo.

What is proc uptime?

Using /proc/uptime Shows how long the system has been on since it was last restarted: $ cat /proc/uptime 350735.47 234388.90. The first number is the total number of seconds the system has been up. The second number is how much of that time the machine has spent idle, in seconds.

How can I check uptime users?

Navigate to Settings>Users to access the Users menu. You can create and manage multiple users on an account, update your profile or change the password on a user account.


2 Answers

Got it...

$sysctl -n kern.boottime | cut -c14-18
87988

Then I just converted that to readable format (don't remember how):

1 Days 00:26:28

like image 130
Ryan Avatar answered Sep 30 '22 10:09

Ryan


There simply is no "/proc" directory on the Macintosh.

On MacOS, you can do a command like:

sysctl kern.boottime 

and you'll get a response like:

kern.boottime: { sec = 1362633455, usec = 0 } Wed Mar  6 21:17:35 2013
like image 33
Michael Dautermann Avatar answered Sep 30 '22 09:09

Michael Dautermann