How to "automatize" rclone?

Hi all!
I have got a question but, first, I'll explain why I am using rclone.
I need a program to do 2 things:

  1. Backup my local files to GDrive
  2. Server-side copy files from a GDrive to another

For the first thing I tried to use "GDrive Backup and Sync" but it has some problems, so I found rclone

Well, I would like to let rclone work continuously but I've seen that this isn't possible. So, I was looking for a way to "automatize" rclone, like executing the command every hour, but without opening the cmd windows (that can be pretty annoying)

Can you help me?

Thanks :slight_smile:

If it matters, I am using rclone 1.51.0

1 Like

there are many ways to get that done on windows.

this will run rclone, wait 5 seconds and loop over
write a .cmd batch file and paste this:

:looper
rclone.exe lsd wasabieast2:
timeout /T 5 > nul
goto looper

if you want to run the script at system start.

  1. use task scheduler - easy
  2. use nssm - complex

this is using task scheduler.

2 Likes

Hi! Thanks for your help

Can you please tell me how does this works?
I don't know the "cmd language.."
I mean, I understand the "looper" and "goto looper"
But... lsd? wasabieast2? timeout /T 5 > nul?

I mean, if you please can comment/explain I can also personalize this small "script"

Thanks :slight_smile:

sure,

  1. change rclone.exe lsd wasabieast2: to whatever rclone command you want to use.
  2. to learn about timeout, from the command line type timeout /?
  3. by default the timeout command prints output to the command line, using >nul hides that output.
    try this timeout /T 5 and see what happens

https://ss64.com/nt/timeout.html
https://ss64.com/nt/goto.html
https://ss64.com/nt/syntax-redirection.html

1 Like

Understood, thanks :slight_smile:

Do you know if there is a way to execute the .cmd without opening the window? So, like a "silent" mode I don't know how to call it.. Just execute the program in the background

yes, use task scheduler.
click the hidden check box

1 Like

Understood thanks :slight_smile:
Last things..

:looper
rclone.exe copy folder1 folder2
rclone.exe copy folder3 folder4
rclone.exe copy folder5 folder6
timeout /T 5 > nul
goto looper

This works in this way
First of all, the first copy starts
When the first copy has finished his job, then the second copy starts
Same thing, when the second copy has finished his job, then the third copy starts
Then it will wait 5 second and loop, right? Each copy waits for the previous copy to finish, right?

Thanks again :slight_smile:

1 Like

each command is run one at a time, when that command is finished, the next command is run.

Really, really, really thanks!

sure,
i was thinking about it and i suggest that you use this for the timeout.

timeout /t 5 /nobreak > nul

/NOBREAK Ignore key presses and wait specified time.

1 Like

Yeah that's nice! Really thanks :slight_smile:

I just finished setting up, all works except this thing
I checked the "hidden" box, but the "cmd windows" continues appearing every time..

I am not sure what that "hidden" box actually does to be honest... maybe it just hides the process or something.

But if you select that the user that runs the script is SYSTEM instead of your user then it will not show up at all. It will just work in the background. You can select this in task scheduler (first options screen).

Well.. This way rclone doesn't start at all, or better, it starts for 1 second and closes immediately

check task mananger, see if rclone.exe is running in the background

Ye I checked with task manager, rclone.exe appears for 1 seconds and closes..

make sure you use a log with rclone.
check the log.

I think I know what the problem is...
When you use a user account (like you normally would if you ran it in windows) the script will start in whereever the file was located.
But I think system account will always start in C:\windows\system32 - and there is no rclone.exe file here so it will get very confused and error/exit.

To fix that, just add a line that spesifically tells the script which folder it should be working in ( I have added an extra line at the top compared to the earlier example:

::First of all, go to the rclone folder
cd c:\rclone

:looper
rclone.exe copy folder1 folder2
rclone.exe copy folder3 folder4
rclone.exe copy folder5 folder6
timeout /T 5 > nul
goto looper

Protip - you can comment your own code for easier readability.
Any line that starts with :: or REM will be ignored by the program.

::This is a comment that does nothing
REM This is also a comment that does nothing

But a line like this in the code will error... because batch does not know what a "But" is ... juvenile snickering

1 Like

Yes but..
Well, I already found out this thing, because the cmd wasn't working on startup.. So I changed the file with those extra 2 lines at the beginning
This is my full file

G:
cd G:\Programs\ProgrammiNonInstallati\rclone-v1.51.0-windows-amd64
:looper
rclone copy "Musica - ccsf:" "Musica - swccd:" --drive-stop-on-upload-limit
rclone copy "Musica - ccsf:" "Musica - g-suit:" --drive-stop-on-upload-limit

rclone copy "Roba - ccsf:" "Roba - swccd:" --drive-stop-on-upload-limit
rclone copy "Roba - ccsf:" "Roba - g-suit:" --drive-stop-on-upload-limit

rclone copy "RRROBA - ccsf:" "RRROBA - g-suit:" --drive-stop-on-upload-limit
rclone copy "RRROBA - ccsf:" "RRROBA - g-suit:" --drive-stop-on-upload-limit

rclone copy "Streaming - ccsf:" "Streaming - g-suit:" --drive-stop-on-upload-limit
rclone copy "Streaming - ccsf:" "Streaming - swccd:" --drive-stop-on-upload-limit

rclone copy "Musica - ccsf:" "Unipi:" --drive-stop-on-upload-limit
rclone copy "Roba - ccsf:" "Unipi:" --drive-stop-on-upload-limit
rclone copy "Streaming - ccsf:" "Unipi:" --drive-stop-on-upload-limit

timeout /t 3600 /nobreak > nul
goto looper

But the problem with SYSTEM user was still there
So, I google a little and found this
image
"Run whether user is logged or or not" yes, but without the second tick (Do not store password)
And now it works, it runs at startup without opening the cmd window

But also tried to make a second file to mount at startup
I have to understand how mount works, with cache etc... But this was a try

G:
cd G:\Programs\ProgrammiNonInstallati\rclone-v1.51.0-windows-amd64

At startup, same settings, it doesn't work if I set "Run whether user is logged on or not"
It works only with "Run only when user is logged on" but with this config the cmd window opens..
rclone mount "Roba - ccsf:" X:

my advice is get all your rclone command working 100% then work on task scheduler and starting apps at startup.
also, you do not need to restart the computer each time to test task scheduler.
enable run on demand then right click the task and click run.

image

if you want to run rclone mount, you should run it as system user, else you might be able to see and use the mount.