Add lockfile logic
This commit is contained in:
parent
2a2ee511f3
commit
8cf6e7612a
1 changed files with 7 additions and 0 deletions
|
@ -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!)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue