-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy patherror-handling-shell.sh
More file actions
35 lines (32 loc) · 1000 Bytes
/
error-handling-shell.sh
File metadata and controls
35 lines (32 loc) · 1000 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#!/bin/bash
#https://encore.tech/automating-red-hat-enterprise-linux-patching-with-ansible-part-2-of-2/
# @brief actions required to be conducted before updates are applied
# and/or servers are rebooted.
logFile="/tmp/pre_update.log"
###########################
# Begin Functions #
function log_msg {
current_time=$(date "+%Y-%m-%d %H:%M:%S.%3N")
log_level=$1
# all arguments except for the first one, since that is the level
log_msg="${@:2}"
echo "[$current_time] $log_level - $log_msg" >> $logFile
}
function log_error {
log_msg "ERROR" "$@"
}
function log_info {
log_msg "INFO " "$@"
}
function log_debug {
log_msg "DEBUG" "$@"
}
# End Functions #
###########################
###########################
# Begin Body #
errorCheck=0
cat /dev/null > $logFile
log_info "========================================================"
log_info "= Pre-update status for $HOSTNAME"
log_info "========================================================"