Skip to content

Commit 2c59e3b

Browse files
author
Martin Mrazik
committed
Add logging to file alongside with STDOUT
1 parent 9fbc368 commit 2c59e3b

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

0/enableagent.sh

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
#!/bin/bash
22
# script for the RM extension install step
3+
LOGFILE="/var/log/enableagent.log"
34

45

56
log_message()
67
{
78
message=$1
8-
echo $(date -u +'%F %T') "$message"
9+
timestamp="$(date -u +'%F %T')"
10+
echo "$timestamp" "$message"
11+
echo "$timestamp" "$message" >> "$LOGFILE"
912
}
1013

1114
decode_string()
@@ -127,6 +130,7 @@ if [ ! -z "$proxy_url_variable" ]; then
127130
fi
128131
fi
129132

133+
log_message "Configuring agent"
130134
OUTPUT=$(sudo -E runuser AzDevOps -c "/bin/bash $dir/config.sh --unattended --url $url --pool \"$pool\" --auth pat --token $token --acceptTeeEula --replace $extra" 2>&1)
131135
retValue=$?
132136
log_message "$OUTPUT"
@@ -138,4 +142,5 @@ fi
138142
# run agent in the background and detach it from the terminal
139143
log_message "Starting agent"
140144
sudo -E nice -n 0 runuser AzDevOps -c "/bin/bash $dir/run.sh $runArgs" > /dev/null 2>&1 &
141-
disown
145+
log_message "disown"
146+
disown

0 commit comments

Comments
 (0)