Skip to content

Commit

Permalink
Merge pull request #5 from bcgov/DBC22-2446
Browse files Browse the repository at this point in the history
DBC22-2446: Fix logic for finding timestamp
  • Loading branch information
wmuldergov authored Jul 10, 2024
2 parents fcb424c + e0d7cac commit f6df9bc
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion compose/openshiftjobs/scripts/analyzeexportlogs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ for file in *.gz; do
# Check if the file exists and is a regular file
if [[ -f $file ]]; then
# Extract the date and time part from the filename (assuming UTC timezone)
file_datetime_utc=$(echo "$file" | grep -oE '[0-9]{10}(?=-access\.log)')
file_datetime_utc=$(echo "$file" | sed -n 's/.*\([0-9]\{10\}\)-access\.log\.gz/\1/p')
# Check if the file date and time in UTC falls within days_ago's start and end time in UTC
if [[ $file_datetime_utc -ge $start_time_utc && $file_datetime_utc -le $end_time_utc ]]; then
zipped_files+=("$file")
Expand Down
4 changes: 2 additions & 2 deletions compose/openshiftjobs/scripts/ziplogs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ log_dir="./logs"

# Iterate over log files
find "$log_dir" -type f -name '*.log' | while read -r file; do
# Extract timestamp from filename
timestamp=$(echo "$file" | grep -oE '[0-9]{10}(?=-access\.log)')
# Extract timestamp from filename ensuring it is followed by '-access.log'
timestamp=$(echo "$file" | sed -n 's/.*\([0-9]\{10\}\)-access\.log/\1/p')

# Check if timestamp is less than or equal to previous hour
if [[ $timestamp -le $previous_hour ]]; then
Expand Down

0 comments on commit f6df9bc

Please sign in to comment.