rClone Scheduling

I have setup rClone and tested on remote server to Google Drive for Plex Cloud.

I have setup Sync on rClone but I am unsure if it keeps running or will have to be scheduled. I have looked all over and may have just missed it.

Thanks in advance.

1 Like

You will need to schedule a sync for every x minutes / x hours or however often you think your content will be updated

Just make bash script (eg rclone-cron.sh ) and put it in crontab. Make sure the script closes if its already running so you dont have multiple iterations of it.

#!/bin/bash
if pidof -o %PPID -x “rclone-cron.sh”; then
exit 1
fi
rclone sync …
exit

2 Likes

Thanks for the advice. I am working with a shared seedbox, do I need admin rights for the bash script and cronjob?

This is not an area I have much experience in so the more detailed answer the better or pointing to the right location.

Thanks again

You need SSH access ( dont need root one )

1 Like

could someone explain in more detail how to do this?

I want to send a rclone command every 30mins

Thank you!

First make a new script eg
nano /path/rclone-cron.sh
inside copy/paste ( put # in front !/binbash , forums marks it as bold font )

#!/bin/bash
if pidof -o %PPID -x “rclone-cron.sh”; then
exit 1
fi
rclone sync …
exit

make file executable

chmod a+x /path/rclone-cron.sh
Put the script in crontab
crontab -e

Make it run at every hour and half, copy paste line bellow in your crontab
0,30 * * * * /path/rclone-cron.sh >/dev/null 2>&1

6 Likes

is it possible to have the command run every 30mins?

thanks!

This is at every whenever is hour and 30 minutes eg 12:30, 13.30 if you want to run it every 30 minutes from when you saved crontab then you can change it to
0/30 * * * * /path/rclone-cron.sh >/dev/null 2>&1
So if you saved crontab -e at 12:15 it will run at 12:45, 13:15 etc…
Personally I prefer to set it by exact times so i know exactly when stuff could be running in background.

1 Like

rclone sync is for both sides to be the same right? … wouldn’t it be better for rclone copy?

rclone sync is rclone copy with delete on dest whatever is missing on source, so not sure what you want to do. With unlimited cloud drives personally I would use copy and not sync so later on when you are out of disk space you can delete local content and still have it on cloud.

1 Like

not able to get this working.

Could you double check my work? I linked 2 screen shots. Trying to get it to run every 15mins now but haven't got it to work at all. Thanks!

change it to

and just run script manually after to see if its running

I also suggest you change rclone flags to

rclone move /home/lowfront/completed/TV/ cloud2: -v --no-traverse --bwlimit 9M --min-age 15m --log-file= /home/lowfront/rclone-upload.log

Its good to have -v and log file on so you can check what was uploaded and if there are any errors.
The no-traverse will speed up your upload a lot as it can take quite a lot for rclone to scan whole destination and since you are moving files eg you dont have tons the same one locally and on cloud it should be used. As for min-age set it to at least 15m eg rclone wont upload files that are not at least 15 minutes old so you avoid the issue of uploading files that are partially copied/moved. ( if your client is just moving them you can set it to 1m )

You can monitor whats happening in log then by
tail -f /home/lowfront/rclone-upload.log
or go trough old all log by
less /home/lowfront/rclone-upload.log

I would also strongly suggest that before you even run rclone move you check if there are any files that need to be uploaded at all eg

if find /home/lowfront/completed/TV/* -type f -mmin +1 | read
then
rclone move /home/lowfront/completed/TV/ cloud2: -v --no-traverse --bwlimit 9M --min-age 15m --log-file= /home/lowfront/rclone-upload.log
fi
exit

I assume you have 9M limit so you can use your net for other things, I think rclone does support scheduling as well eg you could make upload limit faster between 1am - 7am. ( never checked/used it )

Or do it within your script by

TIME=$(date '+%H%M%S')
if [ $TIME -ge 010000 ] -a [ $TIME -le 070000 ]; then 
rclone with bwlimit= 0 (eg max )
else 
rclone with bwlimit= 9M
fi

The only disadvantage with above script compared to proper rclone scheduling is that if sync is in progress at 1am it wont run it until its ended.

1 Like

massive thank you.

how do I try running the script manually?

just do:
/home/lowfront/rclone-cron.sh

p.s. If you add the check for files you can just run sync every minute as script will exit anyway if there is nothing to upload and if there is you want it up asap :slight_smile:
* * * * * /home/lowfront/rclone-cron.sh >/dev/null 2>&1

1 Like

Thanks so much for your help Ajki this is awsome.

I know the script is working by manually activating it. But still can't seem to get the automated task to work.

Here is my latest screenshot

remove command part from crontab -e its just **** / etc…

1 Like

The automation still isn’t working. I noticed if I manually do the script it asks for my rclone configuration password.

Could that be preventing it auto working? Do I need to save my config password somewhere?

Mega thanks again

I think you can set the flag --ask-password false

1 Like

that flag isn’t working. I tired --ask-password no …that didn’t work either.