Skip to content

Instantly share code, notes, and snippets.

@groundcat
Last active May 16, 2020 02:31
Show Gist options
  • Save groundcat/d9214bf775f5d583cfb1ae2e287a0540 to your computer and use it in GitHub Desktop.
Save groundcat/d9214bf775f5d583cfb1ae2e287a0540 to your computer and use it in GitHub Desktop.
Keep rclone running with cronjob

Install rclone:

curl https://rclone.org/install.sh | sudo bash

Configure rclone remote:

rclone config

Create a bash script under /root/rclone.sh : (Replace example:example with your rclone command)

#!/bin/bash
LOCKFILE="/var/lock/`basename $0`"

(
    flock -n 9 || {
	echo "$0 already running"
	exit 1
    }

echo "Starting rclone"
rclone sync example:example example:example --transfers 50 --checkers 50

) 9>$LOCKFILE

Create a log file:

touch /var/log/rclone.log

Add a Cronjob:

crontab -e

Set Cronjob running every 2 minutes:

*/2 * * * * bash /root/rclone.sh > /var/log/rclone.log 2>&1

Check log:

cat /var/log/rclone-cron.log

Check if your rclone.sh is running:

pgrep -f -a rclone.sh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment