From 8cf6e7612a6f3da59ffbee134d7d1e80b46df4bf Mon Sep 17 00:00:00 2001 From: Sebastian Cabrera Date: Mon, 14 Apr 2025 01:04:48 -0400 Subject: [PATCH] Add lockfile logic --- scripts/rclone-sync.sh | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/scripts/rclone-sync.sh b/scripts/rclone-sync.sh index 677a33e..23e6d83 100755 --- a/scripts/rclone-sync.sh +++ b/scripts/rclone-sync.sh @@ -10,6 +10,13 @@ DEST="goji-hetzner:" # Create timestamped log file TIMESTAMP=$(date +"%Y-%m-%d_%H-%M-%S") LOGFILE="$HOME/logs/rclone-sync-$TIMESTAMP.log" +LOCKFILE="/tmp/rclone-sync.lock" + +exec 9>"$LOCKFILE" +if ! flock -n 9; then + echo "rclone sync is already running. exiting...." | tee "$LOGFILE" >&2 + exit 1 +fi # Run rclone and log output to both screen and file using tee (no --log-file!) {