Linux Uptime in Seconds

From Leo's Notes
Revision as of 20:55, 27 May 2013 by Leo (talk | contribs) (Created page with "To get the system's uptime in seconds, you can use /proc/uptime. <syntaxhighlight lang="bash" line start="1" enclose="div"> #!/bin/sh Uptime=$(</proc/uptime) Uptime=${Uptim...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
This page was last edited on 27 May 2013, at 20:55.

To get the system's uptime in seconds, you can use /proc/uptime.


#!/bin/sh

Uptime=$(</proc/uptime)
Uptime=${Uptime%%.*}

echo $Uptime