Problem using sync command with Windows Task Scheduler

What is the problem you are having with rclone?

When i try to execute a simple sync command between a local folder and a folder on OneDrive (crypt remote), it seems to run normally as expected on command line. But when it comes to Windows Task Scheduler (to automate this backup job), the below command seems not be executed. I copied the exact same command that i've checked working on CLI, pasted it to the task action parammeters (with rclone.exe as the executable), and it just doesn't execute, as no log file is generated and the destination is not synced (no test files created on source are synced with destination).

Run the command 'rclone version' and share the full output of the command.

rclone v1.62.2

  • os/version: Microsoft Windows 10 Home Single Language 22H2 (64 bit)
  • os/kernel: 10.0.19045.3208 Build 19045.3208.3208 (x86_64)
  • os/type: windows
  • os/arch: amd64
  • go/version: go1.20.2
  • go/linking: static
  • go/tags: cmount

Which cloud storage system are you using? (eg Google Drive)

OneDrive

The command you were trying to run (eg rclone copy /tmp remote:tmp)

sync "D:\user" ode:Desktop/user --checksum -P --no-console --stats-log-level NOTICE --log-file=D:/user/Documents/rclone/"log update %date:~0,2%-%date:~3,2%-%date:~6,4% %time:~0,2%-%time:~3,2%-%time:~6,2%.log" -vv --drive-use-trash

The rclone config contents with secrets removed.

A log from the command with the -vv flag

There's no log file, it seems the command is not executed

welcome to the forum,

might check out this, need to hardcode all paths including config file and location of rclone.exe

--log-file=D:/user/Documents/rclone/"log
perhaps cut and paste problem?

maybe, if you need environment variables, might try cmd /c c:\path\to\rclone.exe sync ...
or put run a command inside a .cmd and run the .cmd
something like this

for /f "tokens=2 delims==" %%I in ('wmic os get localdatetime /format:list') do set datetime=%%I
set datetime=rclone.%datetime:~0,4%%datetime:~4,2%%datetime:~6,2%.%datetime:~8,2%%datetime:~10,2%%datetime:~12,2%
c:\path\to\rclone.exe sync ...  --log-file=d:\user\documents\rclone\%datetime%.log

Hi,

Like asdffdsa said, you need to specify the full path, for example:

c:\rclone\rclone.exe sync ...

Also, I'm pretty sure you should remove the " from the file name of the log file. If I do

echo  "log update %date:~0,2%-%date:~3,2%-%date:~6,4% %time:~0,2%-%time:~3,2%-%time:~6,2%.log"

It includes the " and that is not valid in a Windows file name. Even when (especially) your rclone command fails, it should generate a log file. If it doesn't, most likely you aren't successfully running the exe

Hey! Thanks for the answer.
Just to be sure if i understood correctly, when setting up the action part on windows task scheduler, i need to select the rclone.exe and also specify the full path of rclone on my pc before the command itself on parameters?
I mean, here where the arrow is poiting:

I need to write:
full/path/to/rclone.exe sync "D:\user" ode:Desktop/user --checksum -P --no-console --stats-log-level NOTICE --log-file=D:/user/Documents/rclone/log update %date:~0,2%-%date:~3,2%-%date:~6,4% %time:~0,2%-%time:~3,2%-%time:~6,2%.log -vv --drive-use-trash

That's what you are saying? Or i missed something?

Something like that, yeah. But you can't have spaces in the path, I'd replace them with underscores. Or encapsulate the whole path in quotation marks, like:

--log-file="D:/user/Documents/rclone/log update %date:~0,2%-%date:~3,2%-%date:~6,4% %time:~0,2%-%time:~3,2%-%time:~6,2%.log"

I'm more familiar with linux so I'm not 100% sure how command arguments work in Task Scheduler, since you are using environment variables you might need to

If you want a more detailed log you can use

--log-level=DEBUG
1 Like

I'm still having issues... Tried everything i could imagine, but nothing solves the problem. The command runs as expected when in CMD, but when it comes to the windows task manager, nothing happens. The log file isn't generated as well.
Its incredible, i did everything exactly the same this guy said here How to setup periodic sync in Windows 10 - #2 by asdffdsa





And i just can't get this simple task done... it's so tough, don't know what else i can do. Maybe i don't have the knowledge of o.s. required to operate rclone, don't know.

hi, i am that guy and imho, you did not do everything exactly the same.
twice now, in this topic and in that topic, i recommended to put the command into a .cmd file.
and run the .cmd from terminal and tasksch.

fwiw, for testing, you can run a task on the fly, without a trigger.
for example, something like
C:\Windows\System32\schtasks.exe /run /tn "rclone\FileHistory back-up rclone"

and your settings, are configured for windows vista/2008?

for testing, use a simple rclone command. get that working, then try more complex commands.
for example
c:\users\karl\rclone.exe version --log-level=DEBUG --log-file=d:/user/documents/rclone/rclone.log

on my system, might look like

c:\data\rclone>type doit.cmd
c:\data\rclone\rclone.exe version --log-level=DEBUG --log-file=c:\data\rclone\rclone.log

c:\data\rclone>doit.cmd

c:\data\rclone>c:\data\rclone\rclone.exe version --log-level=DEBUG --log-file=c:\data\rclone\rclone.log
rclone v1.63.0
- os/version: Microsoft Windows 11 Pro 22H2 (64 bit)
- os/kernel: 10.0.22621.1992 (x86_64)
- os/type: windows
- os/arch: amd64
- go/version: go1.20.5
- go/linking: static
- go/tags: cmount

c:\data\rclone>type c:\data\rclone\rclone.log
2023/07/26 09:44:22 DEBUG : rclone: Version "v1.63.0" starting with parameters ["c:\\data\\rclone\\rclone.exe" "version" "--log-level=DEBUG" "--log-file=c:\\data\\rclone\\rclone.log"]
2023/07/26 09:44:22 DEBUG : rclone: Version "v1.63.0" finishing with parameters ["c:\\data\\rclone\\rclone.exe" "version" "--log-level=DEBUG" "--log-file=c:\\data\\rclone\\rclone.log"]

and in tasksch, for the action, use c:\data\rclone\doit.cmd

1 Like

Hey!
I read all the things you wrote here and here and after following your advice to create .cmd files and execute through windows task manager, it worked out. Thank you.
I don't know why only pasting the commands directly on the action section doesn't work, but it's fine, maybe it require some advanced o.s. knowledge i just don't have currently.
Thank you for your reference on cmd basics, it seems pretty useful, i'll check it out :slight_smile:

good that you got it worked out.

https://www.nirsoft.net/utils/nircmd.html
that site has an amazing list of free command line tools

1 Like

Thank you, mate. Saved here for checking :slight_smile:

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.