Skip to content

Commit

Permalink
Merge pull request #197 from acep-uaf/nicole/fix_dest_path_scada
Browse files Browse the repository at this point in the history
Create dest dir if it doesn't exist
  • Loading branch information
nicolemah99 authored Sep 4, 2024
2 parents 551115b + 037de74 commit 331a764
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion cli_meter/sync-scada-data.sh
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,18 @@ NUM_MONTHS=$(read_config "num_months")
DEST_DIR=$(read_config "dest_dir")
CUR_DATE=$(date +%Y-%m-01)

mkdir -p $DEST_DIR

log "Syncing from $SRC_DIR to $DEST_DIR for the last $NUM_MONTHS months"

# Loop over the number of months specified
for ((i=0; i<NUM_MONTHS; i++)); do
# Calculate the date for each month in the past
cur_timestamp=$(date -d "$CUR_DATE -$i month" +%Y%m)
date_dir=$(date -d "$CUR_DATE -$i month" +%Y-%m)

# Create the destination directory if it doesn't exist
dest_dir_path="$DEST_DIR/$cur_timestamp"
dest_dir_path="$DEST_DIR/$date_dir"

log "Syncing files for timestamp $cur_timestamp to $dest_dir_path"

Expand Down

0 comments on commit 331a764

Please sign in to comment.