Add lockfile logic

This commit is contained in:
Sebastian Cabrera 2025-04-14 01:04:48 -04:00
parent 2a2ee511f3
commit 8cf6e7612a
No known key found for this signature in database

View file

@ -10,6 +10,13 @@ DEST="goji-hetzner:"
# Create timestamped log file # Create timestamped log file
TIMESTAMP=$(date +"%Y-%m-%d_%H-%M-%S") TIMESTAMP=$(date +"%Y-%m-%d_%H-%M-%S")
LOGFILE="$HOME/logs/rclone-sync-$TIMESTAMP.log" 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!) # Run rclone and log output to both screen and file using tee (no --log-file!)
{ {