Skip to content

Commit fa1471d

Browse files
committed
fix date to work on GNU based linux systems per #1023
1 parent 8d3b367 commit fa1471d

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

utils/log-collector

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,18 @@ done
6969

7070
# CloudWatch stores the creationTime as milliseconds since epoch UTC.
7171
# Since macOS doesn't support calculating the time since epoch in milliseconds, we don't have perfect accuracy on this, but it should be as close to 24 hours as possible
72-
# while still being inclusive to all platforms that might run the script
72+
# We'll check to see if we're running on a macOS-based OS and adjust appropriately, otherwise use the standard date command
7373

7474
# Currently only collects the last 24h of logs, but it might be good to be able to specify a different value for this.
75-
logAge=$(date -v-1d "+%s000")
75+
76+
logAge=$(date --date="1day" "+%s000")
77+
78+
# check if we're running on a macOS based system
79+
if [[ $OSTYPE == 'darwin'* ]]; then
80+
logAge=$(date -v-1d "+%s000")
81+
fi
82+
83+
7684

7785
# Collect some information about the Lambda function and associated log groups
7886
lambdaFunction=$(aws cloudformation describe-stack-resources --stack-name "$stackName" --logical-resource-id Autoscaling --query "StackResources[*].PhysicalResourceId" --output text | sed -nr 's/.*stack\/(.*)\/.*/\1/p')

0 commit comments

Comments
 (0)