Skip to content

Instantly share code, notes, and snippets.

@andrewp-as-is
Last active October 13, 2021 19:08
Show Gist options
  • Save andrewp-as-is/b4ce7c690eee348fa626b555dba2ad3b to your computer and use it in GitHub Desktop.
Save andrewp-as-is/b4ce7c690eee348fa626b555dba2ad3b to your computer and use it in GitHub Desktop.
sysctl boottime #sysctl
#!/bin/sh
sysctl -n kern.boottime
sysctl -n kern.boottime | awk '{split($0,a,",");print a[1]}' | grep -oE "[[:digit:]]{1,}"
uptime=$(sysctl -n kern.boottime | awk '{split($0,a,",");print a[1]}' | grep -oE "[[:digit:]]{1,}")
now=$(date +%s)
echo $((now-uptime))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment