diff --git a/pull-logs.sh b/pull-logs.sh index 46d570c..881183b 100644 --- a/pull-logs.sh +++ b/pull-logs.sh @@ -12,10 +12,20 @@ TARGET_DATE=$1 TARGET_TIME=$2 RANGE=$3 -# Combine date and time for start and end times +# Combine date and time for start and end times in ISO 8601 format START=$(date -d "$TARGET_DATE $TARGET_TIME - $RANGE minutes" +"%Y-%m-%d %H:%M:%S") END=$(date -d "$TARGET_DATE $TARGET_TIME + $RANGE minutes" +"%Y-%m-%d %H:%M:%S") +# Debugging output to ensure correct start and end times +echo "START: $START" +echo "END: $END" + +# Ensure that START is before END +if [[ $(date -d "$START" +%s) -ge $(date -d "$END" +%s) ]]; then + echo "Error: START time is greater than or equal to END time." + exit 1 +fi + echo "Collecting logs from $START to $END" # Function to check journalctl logs