Skip to content

Instantly share code, notes, and snippets.

@wh13371
Created February 16, 2021 15:48
Show Gist options
  • Save wh13371/2b2012e89ed7ce3fe97e28c2fc5923f2 to your computer and use it in GitHub Desktop.
Save wh13371/2b2012e89ed7ce3fe97e28c2fc5923f2 to your computer and use it in GitHub Desktop.
#! /bin/bash
_LOGFILE=/home/genesys/.@/$0.log
_NOW=$(date +"%Y-%m-%d %H:%M:%S.%6N")
_EPOCH=$(date +"%s.%6N")
_NOW_UTC=$(date --utc +%FT%T.%6N%Z)
_MSG="test message @ $_NOW_UTC"
_LOG="$(printf '{"timestamp": "%s", "epoch": "%s", "timestamp_utc": "%s", "message": "%s"}' "${_NOW}" "${_EPOCH}" "${_NOW_UTC}" "${_MSG}")"
echo "${_LOG}"
echo "${_LOG}" >> "${_LOGFILE}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment