Skip to content

Instantly share code, notes, and snippets.

@jps3
Created May 17, 2022 17:47
Show Gist options
  • Save jps3/51342a058095c350d3bfa9dc5e1caef1 to your computer and use it in GitHub Desktop.
Save jps3/51342a058095c350d3bfa9dc5e1caef1 to your computer and use it in GitHub Desktop.
Jamf Pro Computer Extension Attribute for system’s last boot timestamp (UTC)
#!/bin/bash
#
# Created by jps3@lehigh.edu on 2022-05-17
#
# Jamf Pro > Settings > Computer Management > Extension Attributes
# Display Name : system-last-boot-timestamp-utc
# Description : Queries system for timestamp of last boot.
# Data Type : Date (YYYY-MM-DD hh:mm:ss)
# Inventory Display : Extension Attributes
# Input Type : Script
#
LAST_BOOT="$(sysctl -n kern.boottime|sed -E 's/^\{ sec = ([0-9]+),.*$/\1/'|TZ="UTC" xargs date -jf '%s' +"%F %T")"
if [[ -n "$LAST_BOOT" ]]; then
echo "<result>${LAST_BOOT}</result>"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment