Created
May 17, 2022 17:47
-
-
Save jps3/51342a058095c350d3bfa9dc5e1caef1 to your computer and use it in GitHub Desktop.
Jamf Pro Computer Extension Attribute for system’s last boot timestamp (UTC)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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