From 8deaafc9062f0ec76b753b46d03c7ee2fbd2f101 Mon Sep 17 00:00:00 2001 From: Skylar Grant Date: Tue, 25 Jun 2024 18:18:35 -0400 Subject: [PATCH] Move the log after stopping so there's one lapse per entry. --- timelapse/README.md | 2 +- timelapse/tl-control | 12 ++++++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/timelapse/README.md b/timelapse/README.md index 397a624..94c7292 100644 --- a/timelapse/README.md +++ b/timelapse/README.md @@ -25,7 +25,7 @@ SYNC_DES_PATH -- Complete path to sync destination directory CRON_DIR -- Complete path to your system's cron.d directory CRON_FILE -- What to name the cron job file. CRON_FREQUENCY -- Will get set by the script when starting a time lapse -CRON_LOG_PATH -- Complete path to output log location, including filename +CRON_LOG_FILE -- Complete path to output log location, including filename CRON_JOB -- Text of the cron job, starting with the user, do not include frequency here ``` diff --git a/timelapse/tl-control b/timelapse/tl-control index 01e4480..f304633 100644 --- a/timelapse/tl-control +++ b/timelapse/tl-control @@ -10,8 +10,8 @@ SYNC_DES_PATH="/mnt/media/TL/to-process" CRON_DIR="/etc/cron.d" CRON_FILE="$CRON_DIR/timelapse" CRON_FREQUENCY="" # Set by prompt -CRON_LOG_PATH="/var/log/${FILE_LIST[0]}.log" -CRON_JOB="root $INSTALL_DIR/${FILE_LIST[0]} >> $CRON_LOG_PATH 2>&1" +CRON_LOG_FILE="/var/log/${FILE_LIST[0]}.log" +CRON_JOB="root $INSTALL_DIR/${FILE_LIST[0]} >> $CRON_LOG_FILE 2>&1" # Check for root/sudo if [ "$EUID" -ne 0 ]; then @@ -75,6 +75,14 @@ stop_tl() { echo "Unable to remove to the file. Exiting" exit 1 fi + echo "Moving log file: $CRON_LOG_FILE" + mv "$CRON_LOG_FILE" "$CRON_LOG_FILE-bak" + if [[ $? -eq 0 ]]; then + echo "Success" + else + echo "Unable to move to the file. Exiting" + exit 1 + fi } # NAS Sync