Skip to content

Instantly share code, notes, and snippets.

@mxyq
Last active August 1, 2022 09:09
Show Gist options
  • Save mxyq/04dac8859b735309e1efe28978aafb55 to your computer and use it in GitHub Desktop.
Save mxyq/04dac8859b735309e1efe28978aafb55 to your computer and use it in GitHub Desktop.
[Log] #Bash #Log
_printargs() {
printf -- "%s" "$1"
printf "\n"
}
_info() {
_printargs "$@"
}
LOGFILE="/opt/backup/mysqldb/backup.log"
log() {
echo "$(date "+%Y-%m-%d %H:%M:%S")" "$1"
echo -e "$(date "+%Y-%m-%d %H:%M:%S")" "$1" >> ${LOGFILE}
}
function log_msg {
echo "[`date '+ %F %T'` ]: $@"
}
$ log_msg "This is sample log message"
[ 2018-08-16 19:56:34 ]: This is sample log message
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment